#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

struct union_find{
    vector<int> par, rank;
    union_find(int n){
        par = vector<int>(n);
        rank = vector<int>(n);
        init(n);
    }
    void init(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }
    int find(int x){
        if(par[x]==x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};
int h,w;
bool Board[100][100];
set<int> E[10001];
bool visited[10001];

string tree2str(int v,bool isblack){
    visited[v]=true;
    vector<string> S;
    for(auto to:E[v]){
        if(!visited[to]){
            S.push_back(tree2str(to,!isblack));
        }
    }
    sort(S.begin(), S.end());
    string ret;
    if(isblack){
        ret+='1';
    }else{
        ret+='0';
    }
    for(auto s:S){
        ret+=s;
    }
    return "("+ret+")";
}

int id(int i,int j){
    return i*100+j;
}

string board2str(){
    union_find UF(10001);
    //10000???????????£???????????¨??????
    //??£???????????§??????
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(Board[i][j]){
                for(int dh=-1;dh<=1;dh++){
                    for(int dw=-1;dw<=1;dw++){
                        if(!dh&&!dw) continue;
                        if(i+dh<0||h<=i+dh||j+dw<0||w<=j+dw) continue;
                        if(Board[i+dh][j+dw]) UF.unite(id(i,j),id(i+dh,j+dw));
                    }
                }
            }else{
                int d[5]={0,-1,0,1,0};
                for(int k=0;k<4;k++){
                    if(i+d[k]<0||h<=i+d[k]||j+d[k+1]<0||w<=j+d[k+1]){
                        UF.unite(id(i,j),10000);
                    }else if(!Board[i+d[k]][j+d[k+1]]){
                        UF.unite(id(i,j),id(i+d[k],j+d[k+1]));
                    }
                }
            }
        }
    }

    //??£??\??¢???????????§??????
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int d[5]={0,-1,0,1,0};
            for(int k=0;k<4;k++){
                if(0<=i+d[k]&&i+d[k]<h&&0<=j+d[k+1]&&j+d[k+1]<w){
                    if(!UF.same(id(i,j),id(i+d[k],j+d[k+1]))){
                        E[UF.find(id(i,j))].insert(UF.find(id(i+d[k],j+d[k+1])));
                        E[UF.find(id(i+d[k],j+d[k+1]))].insert(UF.find(id(i,j)));
                    }
                }else{
                    if(!UF.same(10000,id(i,j))){
                        E[UF.find(id(i,j))].insert(UF.find(10000));
                        E[UF.find(10000)].insert(UF.find(id(i,j)));
                    }
                }
            }
        }
    }
    /*
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<UF.find(i*w+j)<<' ';
        }
        cout<<endl;
    }
    cout<<endl;*/
    return tree2str(UF.find(10000),false);
}

int main(){
    while(cin>>h>>w,h){
        fill(Board[0],Board[100],false);
        fill(visited,visited+10001,false);
        for(int i=0;i<10001;i++) E[i].clear();
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                char c;
                cin>>c;
                Board[i][j]=(c=='#');
            }
        }
        string S1 = board2str();

        cin>>h>>w;
        fill(Board[0],Board[100],false);
        fill(visited,visited+10001,false);
        for(int i=0;i<10001;i++) E[i].clear();
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                char c;
                cin>>c;
                Board[i][j]=(c=='#');
            }
        }
        string S2 = board2str();
        // cout<<S1<<' '<<S2<<endl;
        if(S1==S2){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632