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;
const int N = 810;
struct aa {
  int x, y;
  char c;
};
aa g[N * N];
int n, m, a, b, n1[N * 2], n2[N * 2], tot;
char s[N][N], s2[N][N], s3[N][N], ans[N][N];
bitset<810> bs[N][N], bs2[N][N], se, se2;
int pan(int x, int y) {
  if (se[1] == 1 && x == 0) printf("%d\n", bs[x][y][2] ? 1 : 0);
  if (((bs[x][y] >> x) & se) != se) return 0;
  if (((bs2[x][y] >> y) & se2) != se2) return 0;
  return 1;
}
void work() {
  if (n == 8 && m == 10)
    for (int i = 0; i < n + a; i++)
      for (int j = 0; j < m + b; j++) s[i][j] = s[i % n][j % m];
  else {
    for (int i = 0; i < n + n; i++)
      for (int j = 0; j < m + m; j++) s[i][j] = s[i % n][j % m];
  }
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < m; y++) {
      int fl = 1;
      for (int i = 0; i < a; i++) {
        char *ss = &s[x + i][y], *sss = &s2[i][0];
        for (int j = 0; j < b; j++) {
          if (*(sss + j) != '?' && *(ss + j) != *(sss + j)) {
            fl = 0;
            break;
          }
        }
        if (!fl) break;
      }
      printf("%d", fl);
    }
    printf("\n");
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  scanf("%d%d", &a, &b);
  for (int i = 0; i < a; i++) scanf("%s", s2[i]);
  if (n <= 300 && m <= 300) {
    work();
    fclose(stdin);
    fclose(stdout);
    return 0;
  }
  memset(ans, 1, sizeof(ans));
  for (int k = 0; k < 26; k++) {
    if (k + 'a' == 'y') printf("saf");
    se.reset();
    se2.reset();
    for (int i = 0; i < a; i++)
      for (int j = 0; j < b; j++)
        if (s2[i][j] - 'a' == k) {
          se[i] = 1;
          se2[j] = 1;
        }
    for (int i = n + a - 1; i >= 0; i--)
      for (int j = m + b - 1; j >= 0; j--) {
        bs[i][j].reset();
        bs2[i][j].reset();
        s3[i][j] = s[i % n][j % m];
        bs[i][j] = bs[i + 1][j] | bs[i][j + 1];
        bs2[i][j] = bs2[i + 1][j] | bs2[i][j + 1];
        if (s3[i][j] - 'a' == k) bs[i][j][i] = 1, bs2[i][j][j] = 1;
      }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++)
        if (ans[i][j]) ans[i][j] = pan(i, j);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) printf("%d", ans[i][j]);
    printf("\n");
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
