8 10
cwcwcwcwcw
crcrcrcrcr
cwcwcwcwcw
crcrcrcrcr
cwcwcwcwcw
crcrcrcrcr
cwcwcwcwcw
crcrcrcrcr
12 14
?????r??c?????
?????w????cw?w
??????cr????c?
c?????c??????w
c???????????c?
??c?????cw????
????c?c?c?????
c?????????c???
c?????c?????c?
??????????c??w
?r????c??r????
???w?w??c???c?

0000000000
1010101010
0000000000
1010101010
0000000000
1010101010
0000000000
1010101010

#include <bits/stdc++.h>
using namespace std;
char mat[805][805], Table[405][405];
int N, M, R, C;
int main() {
  scanf("%d %d\n", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%s", mat[i]);
    for (int j = 0; j < M; j++)
      mat[i + N][j] = mat[i + N][j + M] = mat[i][j + M] = mat[i][j];
  }
  scanf("%d %d\n", &R, &C);
  for (int i = 0; i < R; i++) scanf("%s", Table[i]);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      bool pos = true;
      for (int k = 0; k < R; k++) {
        if (!pos) break;
        for (int l = 0; l < C; l++)
          if (Table[k][l] != '?')
            if (Table[k][l] != mat[i + k][j + l]) {
              pos = false;
              break;
            }
      }
      if (pos)
        printf("1");
      else
        printf("0");
    }
    printf("\n");
  }
  return 0;
}
