#include<bits/stdc++.h>
using namespace std;
char c[110][110];
int main(){
int h,w,x1,x2,y1,y2;
cin>>h>>w>>x1>>x2>>y1>>y2;
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cin>>c[i][j];
}
}
for(int i=1;i<=h;i++){
bool f=false;
for(int j=1;j<=w;j++){
if(i>=x1 && i<=x2 && j>=y1 && j<=y2){
cout<<c[i][j];
f=true;
}
}
if(f){
cout<<endl;
}
}
return 0;
}