#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <random>
#include <set>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
typedef  long long ll;
class tree_hashing
{
private:
    static vector<ll> rnum[2];
    static const ll mod[2];
    int V;
    vector<vector<int> > G;
public:
    tree_hashing(int node_size){
        V = node_size;
        G.resize(V);
        random_device rnd;
        mt19937 mt(rnd());
        uniform_int_distribution<> rand1(0,mod[0]-1),rand2(0,mod[1]-1);
        while((int)rnum[0].size() < V){
            rnum[0].push_back(rand1(mt)), rnum[1].push_back(rand2(mt));
        }
    }
    void add_edge(int a, int b){
        G[a].push_back(b),G[b].push_back(a);
    }
    pair<ll,ll> hash_dfs(int u,int p,int d)
    {
        ll res[] = {1LL,1LL};
        for(auto v : G[u]){
            if(v != p){
                auto val = hash_dfs(v,u,d+1);
                res[0] = (res[0] * val.first) % mod[0];
                res[1] = (res[1] * val.second) % mod[1];
            }
        }
        for(int i=0;i<2;i++){
            res[i] = (res[i] + rnum[i][d]) % mod[i];
        }
        return make_pair(res[0],res[1]);
    }
    pair<ll,ll> hash(int root=0)
    {
        return hash_dfs(root,-1,0);
    }
};
vector<ll> tree_hashing::rnum[2];
const ll tree_hashing::mod[] = {1000000007LL, 1000000009LL};

class UF {
private:
    int sz; vector<int> par,nrank,size;
public:
    UF(){}
    UF(int node_size){ sz = node_size; par.resize(sz),nrank.resize(sz),size.resize(sz);
        rep(i,sz){ par[i] = i; nrank[i] = 0; size[i] = 1;} }
    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(nrank[x] < nrank[y]) swap(x,y);
        par[y] = x; size[x] += size[y]; if(nrank[x] == nrank[y]) nrank[x]++; }
    int query(int x){ x = find(x); return size[x]; }
    bool same(int x,int y){ return find(x) == find(y); }
};

UF ca(vector<string> &s){
    int h = s.size();
    int w = s[0].size();
    UF uf(h*w);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='.'){
                if(i>0&&s[i-1][j]=='.'){
                    uf.unite(i*w+j,(i-1)*w+j);
                }
                if(i<h-1&&s[i+1][j]=='.'){
                    uf.unite(i*w+j,(i+1)*w+j);
                }
                if(j>0&&s[i][j-1]=='.'){
                    uf.unite(i*w+j,(i)*w+j-1);
                }
                if(j<w-1&&s[i][j+1]=='.'){
                    uf.unite(i*w+j,(i)*w+j+1);
                }
            }else{
                for(int a=-1;a<2;a++){
                    for(int b=-1;b<2;b++){
                        if(a==0&&b==0)continue;
                        if(i+a>=0&&i+a<h&&j+b>=0&&j+b<w&&s[i][j]==s[i+a][j+b]){
                            uf.unite(i*w+j,(i+a)*w+j+b);
                        }
                    }
                }
            }
        }
    }
    return uf;
}

pair<ll,ll> calc(vector<string>s){
    int h = s.size();
    int w = s[0].size();
    UF uf = ca(s);
    map<int,int>mp;
    int cnt = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(mp.find(uf.find(i*w+j))==mp.end()){
                mp[uf.find(i*w+j)] = cnt;
                cnt++;
            }
        }
    }
    tree_hashing th(cnt+1);
    set<pair<int,int> > st;
    for(int i=0;i<h;i++){
        for(int j=0;j<w-1;j++){
            int x = uf.find(i*w+j);
            int y = uf.find(i*w+j+1);
            if(x==y||st.count(make_pair(x,y))==1||st.count(make_pair(y,x))==1){
                continue;
            }
            if(x==uf.find(0)){
                th.add_edge(mp[x],mp[y]);
            }else{
                vector<string> s2 = s;
                for(int p=0;p<h;p++){
                    for(int q=0;q<w;q++){
                        if(uf.find(p*w+q)!=x&&uf.find(p*w+q)!=y){
                            s2[p][q] = s[i][j+1];
                        }
                    }
                }
                UF uf2 = ca(s2);
                if(uf2.find(0)!=uf2.find(i*w+j+1)){
                    th.add_edge(mp[x],mp[y]);
                }
            }
            st.insert(make_pair(x,y));
        }
    }
    return th.hash();
}



int main(){
    int h1,w1,h2,w2;
    while(cin >> h1 >> w1 &&h1!=0){
        vector<string>s1(h1+2);
        for(int i=0;i<h1;i++)cin >> s1[i+1];
        for(int i=0;i<w1+2;i++){
            s1[0].push_back('.');
        }
        for(int i=0;i<h1;i++){
            s1[i+1] = "."+s1[i+1] + ".";
        }
        for(int i=0;i<w1+2;i++){
            s1[h1+1].push_back('.');
        }
        pair<ll,ll> x1 =calc(s1);
        cin >> h2  >> w2;
        vector<string>s2(h2+2);
        for(int i=0;i<h2;i++)cin >> s2[i+1];
        for(int i=0;i<w2+2;i++){
            s2[0].push_back('.');
        }
        for(int i=0;i<h2;i++){
            s2[i+1] = "."+s2[i+1] + ".";
        }
        for(int i=0;i<w2+2;i++){
            s2[h2+1].push_back('.');
        }
        pair<ll,ll> x2 =calc(s2);
        if(x1==x2){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3380