#include <bits/stdc++.h>

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> Interval;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

int dx[8] = {0,1,-1,0,1,1,-1,-1};
int dy[8] = {1,0,0,-1,1,-1,1,-1};

const int maxn = 105;

char pic[maxn][maxn];
int d[maxn][maxn];
int vis[maxn][maxn];
int cnt;
int H,W;

set<int> G[2*maxn*maxn];
int f[2*maxn*maxn];

bool valid(int x,int y,int xx,int yy){
    if(x < 0 || x > xx+1 || y < 0 || y > yy+1) return false;
    return true;
}

void dfs(int x,int y,int con,char b){
    d[x][y] = con;
    int nn = (b == '#')?8:4;
    for(int i = 0;i < nn;i++){
        int nx = dx[i] + x;
        int ny = dy[i] + y;
        if(valid(nx,ny,H,W) && !d[nx][ny] && pic[nx][ny] == b){
            dfs(nx,ny,con,b);
        }
    }
}

void dfs2(int x,int y,char b){
    int cont = d[x][y];
    vis[x][y] = 1;
    int nn = (b == '#')?8:4;
    for(int i = 0;i < nn;i++){
        int nx = dx[i] + x;
        int ny = dy[i] + y;
        if(valid(nx,ny,H,W) && !vis[nx][ny] && d[nx][ny] == cont){
            dfs2(nx,ny,b);
        }else if (valid(nx,ny,H,W) && d[nx][ny] != f[cont] && d[nx][ny] != cont){
            f[d[nx][ny]] = cont;
            G[cont].insert(d[nx][ny]);
        }
    }
}

map<vector<int>,int> mp;
int get_id(vector<int> &vi){
    if(mp.count(vi)) return mp[vi];
    else{
        mp[vi] = ++cnt;
        return cnt;
    }
}

int dfs3(int cont,char b){
    vector<int> vi;
    if(G[cont].empty()){
        if(b == '.') vi.push_back(-1);
        else vi.push_back(-2);
    }

    for(auto a:G[cont]){
        vi.push_back(dfs3(a,b == '.'?'#':'.'));
    }
    sort(ALL(vi));
    //cout<<vi<<endl;
    return get_id(vi);
}
void init(){
    memset(d,0,sizeof(d));
    memset(vis,0,sizeof(vis));
    memset(f,-1,sizeof(f));
    _for(i,0,2*maxn*maxn) G[i].clear();
    _rep(i,0,H+1) _rep(j,0,W+1) pic[i][j]='.';
    _for(i,1,H+1) _for(j,1,W+1) cin>>pic[i][j];
}

int main(){
    while(scanf("%d %d",&H,&W)&&H&&W){
        //INPUT AREA
        int t = 1;
        cnt = 1;
        mp.clear();
        init();

        _rep(i,0,H+1){
            _rep(j,0,W+1)if(!d[i][j]){
                dfs(i,j,t++,pic[i][j]);
            }
        }

        f[1] = -1;
        _rep(i,0,H+1){
            _rep(j,0,W+1)if(!vis[i][j]){
                dfs2(i,j,pic[i][j]);
            }
        }
        int k1 = dfs3(1,'.');

        scanf("%d %d",&H,&W);
        init();
        t = 1;

        _rep(i,0,H+1){
            _rep(j,0,W+1)if(!d[i][j]){
                dfs(i,j,t++,pic[i][j]);
            }
        }

        f[1] = -1;
        _rep(i,0,H+1){
            _rep(j,0,W+1)if(!vis[i][j]){
                dfs2(i,j,pic[i][j]);
            }
        }
        int k2 = dfs3(1,'.');

        if(k1 == k2) cout <<"yes"<<endl;
        else cout <<"no"<<endl;
    }
    return 0;
}



Measured memory_bytes: 4528