#include<bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define pb push_back
int x1=-1,y1=-1,x2=-1,y2=-1;
int g1=-1,h1=-1,g2=-1,h2=-1;
int n1,m1;int n2,m2;
int total=0;
vector<vector<char>>a(505,vector<char>(505)),tot(505,vector<char>(505));
map<pair<int,int>,int>cnt;
void gan(vector<vector<char>>now){
x2=-1,y2=-1,g2=-1,h2=-1;
for(int i=0;i<n2;i++) for(int j=0;j<m2;j++){
if(x2!=-1&&g2==-1&&now[i][j]=='o') g2=i,h2=j;
if(x2==-1&&now[i][j]=='o') x2=i,y2=j;
}
}
void rotate(vector<vector<char>>&b){
map<pair<int,int>,int>tt;
for(int i=0;i<n2;i++){
for(int j=0;j<m2;j++){
tot[m2-j-1][i]=b[i][j];
// cerr<<m2-j-1<<" "<<i<<" "<<i<<" "<<j<<"\n";
if(tot[m2-j-1][i]=='o') tt[{m2-j-1,i}]=1;
}
}
// for(int i=0;i<n2;i++) {for(int j=0;j<m2;j++) cout<<tot[i][j]<<" ";cout<<"\n";}
cnt=tt;
b=tot;
swap(n2,m2);
gan(b);
}
bool check(){
int d1=x2-x1,d2=y2-y1;
set<pair<int,int>>fi;
int u=0;
pair<int,int>w1;
for(int i=0;i<n1;i++){
for(int j=0;j<m1;j++){
int p,q;
if(a[i][j]=='x') continue;
if(!cnt.count({i+d1,j+d2})){
u++;
w1={j,i};
}
else fi.insert({i+d1,j+d2});
}
}
// cerr<<"1\n";
// cerr<<d1<<" "<<d2<<"d1,d2\n"<<fi.size()<<"\n";
if(fi.size()==total-1){
for(auto y:cnt){
if(!fi.count(y.F)){
cout<<w1.F<<" "<<w1.S<<"\n";
cout<<y.F.S-d2<<" "<<y.F.F-d1<<"\n";
return 1;
}
}
}
fi.clear();u=0;
d1=g2-x1,d2=h2-y1;
for(int i=0;i<n1;i++){
for(int j=0;j<m1;j++){
int p,q;
if(a[i][j]=='x') continue;
if(!cnt.count({i+d1,j+d2})){
u++;
w1={j,i};
}
else fi.insert({i+d1,j+d2});
}
}
if(fi.size()==total-1){
for(auto y:cnt){
if(!fi.count(y.F)){
cout<<w1.F<<" "<<w1.S<<"\n";
cout<<y.F.S-d2<<" "<<y.F.F-d1<<"\n";
return 1;
}
}
}
fi.clear();u=0;
d1=x2-g1,d2=y2-h1;
// cerr<<g1<<" "<<g2<<"\n";
// cerr<<d1<<" "<<d2<<"d1d2\n";
for(int i=0;i<n1;i++){
for(int j=0;j<m1;j++){
int p,q;
if(a[i][j]=='x') continue;
if(!cnt.count({i+d1,j+d2})){
u++;
w1={j,i};
}
else fi.insert({i+d1,j+d2});
}
}
if(fi.size()==total-1){
for(auto y:cnt){
if(!fi.count(y.F)){
cout<<w1.F<<" "<<w1.S<<"\n";
cout<<y.F.S-d2<<" "<<y.F.F-d1<<"\n";
return 1;
}
}
}
fi.clear();u=0;
d1=g2-g1,d2=h2-h1;
for(int i=0;i<n1;i++){
for(int j=0;j<m1;j++){
int p,q;
if(a[i][j]=='x') continue;
if(!cnt.count({i+d1,j+d2})){
u++;
w1={j,i};
}
else fi.insert({i+d1,j+d2});
}
}
if(fi.size()==total-1){
for(auto y:cnt){
if(!fi.count(y.F)){
cout<<w1.F<<" "<<w1.S<<"\n";
cout<<y.F.S-d2<<" "<<y.F.F-d1<<"\n";
return 1;
}
}
}
return 0;
}
void solve(){
cin>>n1>>m1;
for(int i=0;i<n1;i++) for(int j=0;j<m1;j++){
cin>>a[i][j];
if(a[i][j]=='o') total++;
if(x1!=-1&&g1==-1&&a[i][j]=='o') g1=i,h1=j;
if(x1==-1&&a[i][j]=='o') x1=i,y1=j;
}
cin>>n2>>m2;
vector<vector<char>>b(n2+1,vector<char>(m2+1));
for(int i=0;i<n2;i++) for(int j=0;j<m2;j++){
cin>>b[i][j];
if(b[i][j]=='o')
cnt[{i,j}]=1;
if(x2!=-1&&g2==-1&&b[i][j]=='o') g2=i,h2=j;
if(x2==-1&&b[i][j]=='o') x2=i,y2=j;
}
// cerr<<x2<<" "<<y2<<" "<<g2<<" "<<h2<<"\n";
if(check()) return;
rotate(b);
// for(int i=0;i<n2;i++){for(int j=0;j<m2;j++) cout<<b[i][j]<<" ";cout<<"\n";}
// cout<<x2<<" "<<y2<<" "<<g2<<" "<<h2<<"\n";
if(check()) return;
// cerr<<"1\n";
rotate(b);
// for(int i=0;i<n2;i++){for(int j=0;j<m2;j++) cout<<b[i][j]<<" ";cout<<"\n";}
if(check()) return;
rotate(b);
// for(int i=0;i<n2;i++){for(int j=0;j<m2;j++) cout<<b[i][j]<<" ";cout<<"\n";}
if(check()) return;
rotate(b);
// for(int i=0;i<n2;i++){for(int j=0;j<m2;j++) cout<<b[i][j]<<" ";cout<<"\n";}
if(check()) return;
// cout<<y1<<" "<<x1<<"\n"<<y1<<" "<<x1<<"\n";
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);
solve();
return 0;
}