// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
vector<string> blocks[4];

bool judge(vector<string> ban, vector<int> perm) {
  int success = 0;
  for (int i = 0; i < 3; i++) {
    for (int y = 0; y < 4; y++) {
      for (int x = 0; x < 10; x++) {
        int cnt = 0;
        for (int h = 0; h < blocks[perm[i]].size(); h++) {
          for (int w = 0; w < blocks[perm[i]][0].size(); w++) {
            if (y+h >= 4 || x+w >= 10) {
              h=100;
              break;
            }
            if (ban[y+h][x+w] == '#' && blocks[perm[i]][h][w] == '#') {
              h=100;
              break;
            }
            if (blocks[perm[i]][h][w] == '#') {
              cnt++;
            }
          }
        }
        if (cnt == 4) {
          for (int h = 0; h < blocks[perm[i]].size(); h++) {
            for (int w = 0; w < blocks[perm[i]][0].size(); w++) {
              if (y+h >= 4 || x+w >= 10) {
                break;
              }
              if (blocks[perm[i]][h][w] == '#') {
                ban[y+h][x+w] = '#';
              }
            }
          }
          x = y = 100;
          success++;
        }
      }
    }
    if(success!=i+1) return 0;
  }
  //cout << perm[0] << perm[1] << perm[2] << perm[3] << endl;
  return (success == 3);
}

signed main() {
  ios::sync_with_stdio(0);cin.tie(0);
  int x, y;
  for (int i = 0; i < 4; i++) {
    cin >> x >> y;
    string s;
    for (int j = 0; j < x; j++) {
      cin >> s;
      blocks[i].push_back(s);
    }
  }

  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    vector<int> perm = { 0, 1, 2, 3 };
    vector<string> ban(4);
    for (int j = 0; j < 4; j++) {
      cin >> ban[j];
    }
      
    int yes = 0;
    do {
      if (judge(ban, perm)) {
        cout << "Yes" << endl;
        yes = 1;
        break;
      }
    } while(next_permutation(perm.begin(), perm.end()));
    if (!yes) {
      cout << "No" << endl;
    }
  }
}



