#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int dd[] = { 0, 1, 0, -1 };

string makestr(const vector<vector<int>>& edge, int p, int par) {
    vector<string> s;
    for (int c : edge[p]) {
        if (c == par) continue;
        s.push_back("(" + makestr(edge, c, p) + ")");
    }
    sort(s.begin(), s.end());
    string ret = "";
    for (auto& i : s) ret += i;
    return "(" + ret + ")";
}

vector<vector<int>> maketree(const vector<vector<bool>>& s) {
    int h = s.size(), w = s[0].size();
    vector<vector<int>> col(h, vector<int>(w, -1));
    int c = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (col[i][j] > -1) continue;
            col[i][j] = c;
            queue<P> q;
            q.push(P(i, j));
            while (!q.empty()) {
                P p = q.front();
                q.pop();
                int pi = p.first, pj = p.second;
                if (s[pi][pj]) {
                    for (int i = -1; i < 2; ++i) {
                        for (int j = -1; j < 2; ++j) {
                            int ti = pi + i, tj = pj + j;
                            if (ti >= 0 && ti < h && tj >= 0 && tj < w && s[ti][tj] && col[ti][tj] == -1) {
                                col[ti][tj] = c;
                                q.push(P(ti, tj));
                            }
                        }
                    }
                }
                else {
                    for (int i = 0; i < 4; ++i) {
                        int ti = pi + dd[i], tj = pj + dd[i ^ 1];
                        if (ti >= 0 && ti < h && tj >= 0 && tj < w && !s[ti][tj] && col[ti][tj] == -1) {
                            col[ti][tj] = c;
                            q.push(P(ti, tj));
                        }
                    }
                }
            }
            ++c;
        }
    }
    vector<vector<bool>> isedge(c, vector<bool>(c));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (i + 1 < h) {
                isedge[col[i][j]][col[i + 1][j]] = true;
                isedge[col[i + 1][j]][col[i][j]] = true;
            }
            if (j + 1 < w) {
                isedge[col[i][j]][col[i][j + 1]] = true;
                isedge[col[i][j + 1]][col[i][j]] = true;
            }
        }
    }
    vector<vector<int>> edge(c);
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            if (i != j && isedge[i][j])
                edge[i].push_back(j);
        }
    }
    return edge;
}

int main() {
    while (true) {
        int h1, w1;
        cin >> h1 >> w1;
        if (!h1) return 0;
        h1 += 2;
        w1 += 2;
        vector<vector<bool>> s1(h1, vector<bool>(w1));
        for (int i = 1; i < h1 - 1; ++i) {
            string s;
            cin >> s;
            for (int j = 1; j < w1 - 1; ++j)
                s1[i][j] = s[j - 1] == '#';
        }
        int h2, w2;
        cin >> h2 >> w2;
        h2 += 2;
        w2 += 2;
        vector<vector<bool>> s2(h2, vector<bool>(w2));
        for (int i = 1; i < h2 - 1; ++i) {
            string s;
            cin >> s;
            for (int j = 1; j < w2 - 1; ++j)
                s2[i][j] = s[j - 1] == '#';
        }
        if (makestr(maketree(s1), 0, -1) == makestr(maketree(s2), 0, -1))
            cout << "yes\n";
        else
            cout << "no\n";
    }
}



Measured memory_bytes: 3248