#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int h,w;
cin>>h>>w;
char m[h+5][w+5];
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cin>>m[i][j];
}
}
int x1,x2,y1,y2;
cin>>x1>>x2>>y1>>y2;
for(int i=x1;i<=y1;i++){
for(int j=x2;j<=y2;j++){
cout<<m[i][j];
}
cout<<"\n";
}
}