#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

void make_tree(char [102][102], int, int, vector<int>[10000]);
string tree_str(vector<int>[10000], int n);

int main(){
    while(1){

        int h1,w1;
        char p1[102][102];
        cin >> h1 >> w1;
        
        if(h1==0 && w1==0){
            break;
        }
        
        for(int i=0; i<=h1+1; i++){
            for(int j=0; j<=w1+1; j++){
                if(i==0 || i==h1+1 || j==0 || j==w1+1){
                    p1[i][j]='.';
                }else{
                    cin >> p1[i][j];
                }
            }
        }
        
        int h2,w2;
        char p2[102][102];
        cin >> h2 >> w2;
        for(int i=0; i<=h2+1; i++){
            for(int j=0; j<=w2+1; j++){
                if(i==0 || i==h2+1 || j==0 || j==w2+1){
                    p2[i][j]='.';
                }else{
                    cin >> p2[i][j];
                }
            }
        }
        
        vector<int> tree1[10000];
        vector<int> tree2[10000];
        
        
        make_tree(p1,h1+2,w1+2,tree1);
        make_tree(p2,h2+2,w2+2,tree2);
        
        if(tree_str(tree1,0) == tree_str(tree2,0)){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }

    }
    return 0;
    
}


void make_tree(char p[102][102], int h, int w, vector<int> tree[10000]){
    int cnt=0;
    int num[102][102];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            num[i][j]=-1;
        }
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(num[i][j]!=-1){
                continue;
            }
            
            if(cnt>0){
                tree[num[i-1][j]].push_back(cnt);
            }
            
            queue<pair<int,int> > que;
            
            num[i][j]=cnt;
            que.push(make_pair(i,j));
            
            while(!que.empty()){
                int temph=que.front().first;
                int tempw=que.front().second;

                
                if(p[temph][tempw]=='.'){       //white
                    for(int dh=-1; dh<=1; dh++){
                        for(int dw=-1; dw<=1; dw++){
                            
                            if(dh==0 || dw==0){
                                if(temph+dh>=0 && temph+dh<h && tempw+dw>=0 && tempw+dw<w){
                                    if(p[temph+dh][tempw+dw]=='.' && num[temph+dh][tempw+dw]==-1){
                                        num[temph+dh][tempw+dw]=cnt;
                                        que.push(make_pair(temph+dh,tempw+dw));
                                    }
                                }
                            }
                            
                        }
                    }
                }else if(p[temph][tempw]=='#'){ //black
                    for(int dh=-1; dh<=1; dh++){
                        for(int dw=-1; dw<=1; dw++){

                            if(temph+dh>=0 && temph+dh<h && tempw+dw>=0 && tempw+dw<w){
                                if(p[temph+dh][tempw+dw]=='#' && num[temph+dh][tempw+dw]==-1){
                                    num[temph+dh][tempw+dw]=cnt;
                                    que.push(make_pair(temph+dh,tempw+dw));
                                }
                            }
                        
                        }
                    }
                }
                
                que.pop();
            }
            
            cnt++;
        }
    }
}



string tree_str(vector<int> tree[10000], int n){
    if(tree[n].size()==0){
        return "()";
    }else{
        vector<string> temp;
        for(auto x: tree[n]){
            temp.push_back(tree_str(tree,x));
        }
        sort(temp.begin(),temp.end());
        
        string str="";
        for(auto s: temp){
            str+=s;
        }
        return "("+str+")";
    }
}



Measured memory_bytes: 3584