#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

// undirected
void addEdge(Graph& G, int x, int y) {
    G[x].emplace_back(y);
    G[y].emplace_back(x);
}

string Tree2Str(int now, int pre, const Graph& G) {
    vector<string> vs;
    for (auto nxt : G[now]) {
        if (nxt == pre) continue;
        vs.emplace_back(Tree2Str(nxt, now, G));
    }
    sort(all(vs));
    string ret = "(";
    for (auto s : vs) ret += s;
    ret += ")";
    return ret;
}

main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    while(1) {
        vector<string> v;

        rep(q, 2) {
            int h, w;
            cin >> h >> w;
            if (!h) return 0;
            vvi a(h + 2, vi(w + 2)); // 0:'.', 1:'#'
            rep2(i, 1, h + 1) {
                string s;
                cin >> s;
                rep2(j, 1, w + 1) {
                    a[i][j] = (s[j - 1] == '#');
                }
            }
            h += 2;
            w += 2;

            auto inside = [&](int x, int y) {
                return 0 <= x && x < h && 0 <= y && y < w;
            };

            int c = 0;
            vvi b(h, vi(w, -1));
            function<void(int,int)> dfs = [&](int i, int j) {
                b[i][j] = c;
                rep(k, a[i][j] ? 8 : 4) {
                    int ni = i + dx[k], nj = j + dy[k];
                    if (!inside(ni, nj)) continue;
                    if (a[ni][nj] != a[i][j]) continue;
                    if (b[ni][nj] != -1) continue;
                    dfs(ni, nj);
                }
            };

            rep(i, h) {
                rep(j, w) {
                    if (b[i][j] == -1) {
                        dfs(i, j);
                        c++;
                    }
                }
            }

            Graph G(c);
            set<Pii> st;
            rep(i, h) {
                rep(j, w) {
                    rep(k, 4) {
                        int ni = i + dx[k], nj = j + dy[k];
                        if (!inside(ni, nj)) continue;
                        int c1 = b[i][j], c2 = b[ni][nj];
                        if (c1 == c2) continue;
                        if (c1 > c2) swap(c1, c2);
                        if (st.count(Pii(c1, c2))) continue;
                        addEdge(G, c1, c2);
                        st.insert(Pii(c1, c2));
                    }
                }
            }

            v.emplace_back(Tree2Str(0, -1, G));
        }

        cout << (v[0] == v[1] ? "yes" : "no") << endl;
    }
}

Measured memory_bytes: 3432