#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
        #include<functional>
   //   #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
        int dy[8] = {0, 1, 0, -1,-1,1,-1,1};
        //----------------kokomade temple------------

int h,w,x,y;
int a[105][105]={0},b[105][105]={0};
int ma[105][105]={0},mb[105][105]={0};
string q[10010]; 
vector<int> G[10003];
string dfs(int i){
	if(q[i]!="") return q[i];
	if(G[i].size()==0) return "[]";
	else{
		vector<string> www;
		for(int j=0;j<G[i].size();j++) www.push_back(dfs(G[i][j]));
		sort(www.begin(),www.end());
		string s="";
		for(int j=0;j<G[i].size();j++)s+=("("+www[j]+")");
		return "["+s+"]";
		
	}	
	
	
}


string  solvea(){
	//vector<int> G[10003];
	for(int i=0;i<10003;i++) G[i].clear();
	for(int i=0;i<105;i++) for(int j=0;j<105;j++) a[i][j]=0,ma[i][j]=0;
	
	for(int i=1;i<=h;i++){
		string s;
		cin>>s;
		for(int j=1;j<=w;j++){
			if(s[j-1]=='#') a[i][j]=1;
		}
	}
	int d=0;
	for(int i=0;i<105;i++) for(int j=0;j<105;j++){
		if(ma[i][j]!=0) continue;
		int e=4;
		d++;
		if(a[i][j]==1) e=8;
		
		stack<pa> st;
		
		st.push(make_pair(i,j));
		while(st.size()>0){
			pa r=st.top();
			st.pop();
			x=r.first,y=r.second;
			if(ma[x][y]==0) ma[x][y]=d;
			for(int r=0;r<e;r++){
				if(x+dx[r]<0 || y+dy[r]<0 || x+dx[r]>=105 || y+dy[r]>=105 ) continue;
				if(ma[x+dx[r]][y+dy[r]]!=0) continue;
				if(a[i][j]!=a[x+dx[r]][y+dy[r]]) continue;
				st.push(make_pair(x+dx[r],y+dy[r]));
			}
			
		
		}
		
		
	}
	/*
	for(int i=0;i<30;i++){
		for(int j=0;j<30;j++){cout<<ma[i][j]<<" ";
	}cout<<endl;
	}*/
	
	for(int i=0;i<105;i++){
		for(int j=0;j<104;j++){
			if(ma[i][j]==ma[i][j+1]) continue;
			int aa=ma[i][j],aaa=ma[i][j+1];
			if((find(G[aa].begin(),G[aa].end(),aaa)!=G[aa].end())||(find(G[aaa].begin(),G[aaa].end(),aa)!=G[aaa].end())){
				continue;
			}
			G[min(aa,aaa)].push_back(max(aa,aaa));
		}
	}/*
	for(int i=1;i<=d;i++){
		cout<<i<<"th";
		for(int j=0;j<G[i].size();j++)cout<<G[i][j]<<" ";
		cout<<endl;
	}*/
	for(int i=0;i<10005;i++) q[i]="";
	string s;
	s=dfs(1);
	return s;
}



signed main(){
	while(cin>>h>>w){
		if(h==0) break;
		string s,t;
		s=solvea();
		cin>>h>>w;
		t=solvea();
	//	cout<<s<<endl<<t<<endl;
		if(s==t) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}

return 0;
        }
        
// printf("%.10f\n", ans);

Measured memory_bytes: 3736