#include <bits/stdc++.h>
using namespace std;
int main() {
int h, w, i, j, r1, r2 , c1, c2, a, b;
char ch;
cin >> h >> w >> r1 >> c1 >> r2 >> c2;
a=r1;
b=c1;
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
cin >> ch;
if(i==a&&j==b){
cout << ch;
if((a+1)>=r1&&(a+1)<=r2){
a++;
}
if((b+1)>=c1&&(b+1)<=c2){
b++;
}
}
}
}
}