#include<bits/stdc++.h>
 
using namespace std;
 
struct UnionFind
{
  vector< int > data;
 
  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }
 
  bool operator()(int a, int b)
  {
    a = (*this)[a], b = (*this)[b];
    if(a == b) return (false);
    if(data[a] > data[b]) swap(a, b);
    data[a] += data[b];
    data[b] = a;
    return (true);
  }
 
  int operator[](int a)
  {
    if(data[a] < 0) return (a);
    return (data[a] = (*this)[data[a]]);
  }
 
};
 
int H, W;
string P[102];
 
bool used[102 * 102];
vector< vector< int > > g;
 
string hashed(int idx)
{
  vector< string > ff;
  for(int to : g[idx]) ff.push_back(hashed(to));
  sort(begin(ff), end(ff));
  return (">" + accumulate(begin(ff), end(ff), string()) + "<");
}
 
string get()
{
  cin >> H >> W;
  if(H == 0) exit(0);
 
  P[0] = P[H + 1] = string(W + 2, '.');
  for(int i = 1; i <= H; i++) {
    cin >> P[i];
    P[i] = "." + P[i] + ".";
  }
  H += 2, W += 2;
 
  auto ei1333 = [&](int y, int x)
  {
    return (x * H + y);
  };
 
  UnionFind tree(H * W);
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(i > 0 && P[i - 1][j] == P[i][j]) tree(ei1333(i - 1, j), ei1333(i, j));
      if(j > 0 && P[i][j - 1] == P[i][j]) tree(ei1333(i, j - 1), ei1333(i, j));
      if(P[i][j] == '#') {
        if(P[i - 1][j - 1] == '#') tree(ei1333(i - 1, j - 1), ei1333(i, j));
        if(P[i - 1][j + 1] == '#') tree(ei1333(i - 1, j + 1), ei1333(i, j));
      }
    }
  }
 
  memset(used, false, sizeof(used));
  used[tree[ei1333(0, 0)]] = true;
  g.clear();
  g.resize(W * H);
  for(int i = 0; i < H; i++) {
    for(int j = 1; j < W; j++) {
      int p = tree[ei1333(i, j - 1)], q = tree[ei1333(i, j)];
      if(used[q]) swap(p, q);
      if(p == q || used[q]) continue;
      g[p].push_back(q);
      used[q] = true;
    }
  }
  return (hashed(ei1333(0, 0)));
}
 
int main()
{
  while(true) {
    if(get() == get()) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}