#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

vector<string> input(int h,int w){
    vector<string> p(h+2);
    rep(i,0,h+2) p[i].assign(w+2,'.');
    rep(i,1,h+1){
        string s;
        cin >> s;
        rep(j,0,w) p[i][1+j]=s[j];
    }
    return p;
}

pair<vector<set<int>>,int> make_tree(vector<string> p){
    int h=p.size(),w=p[0].size();
    vector<vector<int>> g(h,vector<int>(w,-1));
    vector<set<int>> res;
    vector<int> dy={0,-1,0,1,-1,-1,1,1},dx={1,0,-1,0,1,-1,-1,1};
    function<void(int,int,int)> dfs=[&](int y,int x,int i){
        g[y][x]=i;
        rep(j,0,p[y][x]=='.'?4:8){
            int ny=y+dy[j],nx=x+dx[j];
            if(ny<0 or h<=ny or nx<0 or w<=nx) continue;
            if(p[y][x]==p[ny][nx] and g[ny][nx]==-1) dfs(ny,nx,i);
            if(p[y][x]!=p[ny][nx] and g[ny][nx]!=-1){
                res[i].insert(g[ny][nx]);
                res[g[ny][nx]].insert(i);
            }
        }
    };
    rep(y,0,h) rep(x,0,w) if(g[y][x]==-1){
        res.push_back({});
        dfs(y,x,res.size()-1);
    }
    return make_pair(res,0);
}

template<class graph_type> string normalization(const graph_type& tree,int root,int parent){
    vector<string> vs;
    for(int child:tree[root]){
        if(child==parent) continue;
        vs.push_back(normalization(tree,child,root));
    }
    sort(vs.begin(),vs.end());
    string res("(");
    for(auto& s:vs) res+=s;
    res+=')';
    return res;
}

template<class graph_type> bool tree_isomorpshism(const pair<graph_type,int> &t1,const pair<graph_type,int> &t2){
    return normalization(t1.first,t1.second,-1)==normalization(t2.first,t2.second,-1);
}

void solve(int h1,int w1){
    auto p1=input(h1,w1);
    int h2,w2;
    cin >> h2 >> w2;
    auto p2=input(h2,w2);
    auto t1=make_tree(p1),t2=make_tree(p2);
    if(tree_isomorpshism(t1,t2)) cout << "yes" << endl;
    else cout << "no" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    for(;;){
        int h1,w1;
        cin >> h1 >> w1;
        if(!h1 and !w1) break;
        solve(h1,w1);
    }
    return 0;
}