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

struct UnionFind {
    vector<int> par;
    int cnt;
    UnionFind(int size_) : par(size_, -1), cnt(size_) {}
    void unite(int x, int y) {
        if ((x = find(x)) != (y = find(y))) {
            if (par[y] < par[x]) swap(x, y);
            par[x] += par[y]; par[y] = x; cnt--;
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
    int size(int x) { return -par[find(x)]; }
    int size() { return cnt; }
};


char pic[110][110];
int component[110][110];// , component2[110][110];

set<int> graph[20000];

int h, w;

bool inside(int r, int c) {
    return 0 <= r && r <= h + 1 && 0 <= c && c <= w + 1;
}

int pos2id(int r, int c) {
    // !!
    return r * (w + 2) + c;
}

string f(int v, int p) {
    // cerr << "visit " << v << endl;
    vector<string> s;
    for (int c : graph[v]) {
        if (c == p) continue;
        s.push_back(f(c, v));
    }
    sort(s.begin(), s.end());
    string ret = "";
    for (string ss : s) ret += ss;
    return "(" + ret + ")";
}

string encode(int h, int w) {
    // テ・ツ按敕ヲツ慊淌・ツ個?
    for (int r = 0; r <= h + 1; r++) {
        for (int c = 0; c <= w + 1; c++) {
            pic[r][c] = '.';
        }
    }
    for (int v = 0; v < 20000; v++) graph[v].clear();

    for (int r = 1; r <= h; r++) {
        string p;
        cin >> p;
        for (int c = 1; c <= w; c++) {
            pic[r][c] = p[c - 1];
        }
    }

    UnionFind uf((h + 2) * (w + 2));
    // テゥツ?」テァツオツ静ヲツ按静・ツ按?」ツつ津ヲツァツ凝ァツッツ?
    for (int r = 0; r <= h + 1; r++) {
        for (int c = 0; c <= w + 1; c++) {
            for (int dr = -1; dr <= 1; dr++) {
                for (int dc = -1; dc <= 1; dc++) {
                    int nr = r + dr,
                        nc = c + dc;
                    if (!inside(nr, nc)) continue;

                    if (pic[r][c] == '.' && abs(dr) == 1 && abs(dc) == 1) continue;

                    if (pic[r][c] != pic[nr][nc]) continue;
                    int id1 = pos2id(r, c),
                        id2 = pos2id(nr, nc);
                    uf.unite(id1, id2);
                }
            }
        }
    }

    // テ」ツ?敕」ツつ古」ツ?古・ツ青ォテ」ツ?セテ」ツつ古」ツつ凝ゥツ崢?・ツ青暗」ツ?ョidテ」ツつ津ィツィツュテ・ツョツ?
    for (int r = 0; r <= h + 1; r++) {
        for (int c = 0; c <= w + 1; c++) {
            component[r][c] = uf.find(pos2id(r, c));
        }
    }

    /*
    cout << "=====" << endl;
    for (int r = 0; r <= h + 1; r++) {
        for (int c = 0; c <= w + 1; c++) {
            // cout << component[r][c];
            printf("%3d", component[r][c]);
        }
        cout << endl;
    }
    cout << "=====" << endl;
    */

    for (int r = 0; r <= h + 1; r++) {
        for (int c = 0; c <= w + 1; c++) {
            if (pic[r][c] != '.') continue;

            for (int dr = -1; dr <= 1; dr++) {
                for (int dc = -1; dc <= 1; dc++) {
                    int nr = r + dr,
                        nc = c + dc;
                    if (!inside(nr, nc)) continue;

                    if (pic[r][c] == pic[nr][nc]) continue;
                    if (r == nr && c == nc) continue;
                    int id1 = component[r][c],
                        id2 = component[nr][nc];
                    graph[id1].insert(id2);
                    graph[id2].insert(id1);
                }
            }
        }
    }

    for (int r = 0; r <= h + 1; r++) {
        for (int c = 0; c <= w + 1; c++) {
            int id = pos2id(r, c);
            if (graph[id].size() == 0) continue;
            /*
            cout << "[" << id << "] ";
            for (int c : graph[id]) cout << c << " ";
            cout << endl;
            */
        }
    }

    return f(component[0][0], -5000000);
    // return "";
}

int main() {
    while (cin >> h >> w, h | w) {

        string res1 = encode(h, w);

        cin >> h >> w;
        string res2 = encode(h, w);

        if (res1 == res2) cout << "yes" << endl;
        else cout << "no" << endl;
    }

    return 0;
}