#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//  17:50-
//A 17:54 AC
//B 17:58 AC
//C 18:05 AC
//D 18:23 AC
//E 19:06 AC
//F 19:52 WA
/*

*/
llint hash_tree(int ter,int per,const vector<vector<int>>&go){
	vector<llint>koha;
	//cerr<<"ter="<<ter<<endl;
	for(auto it:go[ter]){
		if(it==per){continue;}
		koha.pub(hash_tree(it,ter,go));
	}
	SO(koha);
	llint ans=96;
	//bigで割っていく
	for(int i=0;i<koha.size();i++){
		llint t=i%4+i%301+(i*i)%73 + 21;
		ans+=t*koha[i];
		ans%=big;
	}
	return ans;
}
llint so(int H,int W){
	int i,j,x,y;
	vector<string>mat(H+4);
	for(i=2;i<=H+1;i++){cin>>mat[i];mat[i].insert(mat[i].begin(),'.');mat[i].pub('.');mat[i].insert(mat[i].begin(),'.');mat[i].pub('.');}
	mat[0]=string(W+4,'.');
	mat[1]=string(W+4,'.');
	mat[H+2]=string(W+4,'.');
	mat[H+3]=string(W+4,'.');
	vector<vector<int>>ren(H+4,vector<int>(W+4));
	for(i=1;i<=H+2;i++){
		for(j=1;j<=W+2;j++){ren[i][j]=-1;}
	}
	queue<pair<int,int>>que;
	int ban=0;
	for(i=1;i<=H+2;i++){
		for(j=1;j<=W+2;j++){
			if(ren[i][j]!=-1){continue;}
			que.push(mp(i,j));
			ren[i][j]=ban;
			while(que.size()){
				int y=que.front().fir;
				int x=que.front().sec;
				que.pop();
				if(ren[y-1][x]==-1&&mat[y][x]==mat[y-1][x]){ren[y-1][x]=ban;que.push(mp(y-1,x));}
				if(ren[y+1][x]==-1&&mat[y][x]==mat[y+1][x]){ren[y+1][x]=ban;que.push(mp(y+1,x));}
				if(ren[y][x-1]==-1&&mat[y][x]==mat[y][x-1]){ren[y][x-1]=ban;que.push(mp(y,x-1));}
				if(ren[y][x+1]==-1&&mat[y][x]==mat[y][x+1]){ren[y][x+1]=ban;que.push(mp(y,x+1));}
				if(mat[y][x]=='#'){
					if(ren[y-1][x-1]==-1&&mat[y][x]==mat[y-1][x-1]){ren[y-1][x-1]=ban;que.push(mp(y-1,x-1));}
					if(ren[y+1][x-1]==-1&&mat[y][x]==mat[y+1][x-1]){ren[y+1][x-1]=ban;que.push(mp(y+1,x-1));}
					if(ren[y-1][x+1]==-1&&mat[y][x]==mat[y-1][x+1]){ren[y-1][x+1]=ban;que.push(mp(y-1,x+1));}
					if(ren[y+1][x+1]==-1&&mat[y][x]==mat[y+1][x+1]){ren[y+1][x+1]=ban;que.push(mp(y+1,x+1));}
				
				}
			}
			ban++;
		}
	}
	//cerr<<"ban="<<ban<<endl;
	vector<vector<int>>go(ban);
	set<pair<int,int>>aru;
	for(i=1;i<=H+2;i++){
		for(j=1;j<=W+2;j++){
			if(ren[i][j]!=ren[i][j+1]){
				int na=ren[i][j];
				int nb=ren[i][j+1];
				if(na>nb){swap(na,nb);}
				if(aru.count(mp(na,nb))==0){aru.ins(mp(na,nb));go[na].pub(nb);go[nb].pub(na);}
			}
			if(ren[i][j]!=ren[i+1][j]){
				int na=ren[i][j];
				int nb=ren[i+1][j];
				if(na>nb){swap(na,nb);}
				if(aru.count(mp(na,nb))==0){aru.ins(mp(na,nb));go[na].pub(nb);go[nb].pub(na);}
			}
		}
	}
	
	/*for(i=0;i<ban;i++){
		cerr<<"ban i="<<i<<endl;
		for(auto it:go[i]){
			cerr<<i<<" "<<it<<endl;
		}
	}*/
	//goの木ができたので再帰する
	return hash_tree(0,-1,go);
}

bool solve(void){
	int Ha,Wa,Hb,Wb;cin>>Ha>>Wa;
	if(Ha==0){return false;}
	llint A=so(Ha,Wa);
	cin>>Hb>>Wb;
	llint B=so(Hb,Wb);
	cout<<(A==B?"yes":"no")<<endl;
	return true;
}
int main(void){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3252