#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 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;
}

string bp(vector<vector<int> > &v,int i){
    if(v[i].size()==0)return "()";
    vector<string> s;
    for(auto x:v[i]){
        s.push_back(bp(v,x));
    }
    sort(s.begin(),s.end());
    string ans = "(";
    for(auto x:s){
        ans +=x;
    }
    ans += ")";
    return ans;
}

string 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++;
            }
        }
    }
    vector<vector<int> > v(cnt);
    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)){
                v[mp[x]].push_back(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)){
                    v[mp[x]].push_back(mp[y]);
                }
            }
            st.insert(make_pair(x,y));
        }
    }
    return bp(v,mp[uf.find(0)]);
}



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('.');
        }
        string 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('.');
        }
        string x2 =calc(s2);
        if(x1==x2){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3304