#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

const int H = 4;
const int W = 10;

int minoH[4], minoW[4];
char mino[4][4][5];

bool A[4][11];

set<ll> ss;

void gen(int now = 0, int use = 0) {

  if (use == now) gen(now+1, use);

  if (use >= 3) {
    ll bit = 0;

    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
        bit = (bit << 1) + A[i][j];

    assert(__builtin_popcountll(bit) == 4 * 3);
    ss.insert(bit);

    return;

  } else {
    for(int y=0; y+minoH[now]<=4; y++) {
      for(int x=0; x+minoW[now]<=10; x++) {
        bool ok = true;

        for(int i=0; i<minoH[now]; i++)
          for(int j=0; j<minoW[now]; j++)
            ok &= !A[y+i][x+j] || mino[now][i][j] == '.';

        if (!ok) continue;

        for(int i=0; i<minoH[now]; i++)
          for(int j=0; j<minoW[now]; j++)
            A[y+i][x+j] |= mino[now][i][j] == '#';

        gen(now+1, use+1);

        for(int i=0; i<minoH[now]; i++)
          for(int j=0; j<minoW[now]; j++)
            A[y+i][x+j] ^= mino[now][i][j] == '#';
      }
    }

  }
}

int main(){
  int N;
  char B[4][11];

  for(int i=0; i<4; i++) {
    scanf("%d%d", minoH+i, minoW+i);

    for(int j=0; j<minoH[i]; j++)
      scanf("%s", mino[i][j]);
  }

  gen();

  debug(ss.size());

  scanf("%d", &N);

  for(int i=0; i<N; i++) {
    ll bit = 0;
    for(int j=0; j<H; j++) {
      scanf("%s", B[j]);

      debug(B[j]);
      for(int k=0; k<W; k++)
        bit = (bit << 1) + (B[j][k] == '#');
    }


    bit ^= (1LL << (W * H)) - 1;

    if (ss.find(bit) != ss.end()) {
      puts("Yes");
    } else {
      puts("No");
    }
  }

  return 0;
}

