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 = 410;
char mp[N * 2][N * 2], pat[N][N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", mp[i]);
  for (int i = 0; i < n; i++)
    for (int j = m; j < (m << 1); j++) mp[i][j] = mp[i][j - m];
  for (int i = n; i < (n << 1); i++)
    for (int j = 0; j < (m << 1); j++) mp[i][j] = mp[i - n][j];
  int r, c;
  scanf("%d%d", &r, &c);
  for (int i = 0; i < r; i++) scanf("%s", pat[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int flag = 1;
      for (int k = 0; k < r; k++)
        for (int l = 0; l < c; l++)
          if (pat[k][l] != '?' && mp[i + k][j + l] != pat[k][l]) {
            flag = 0;
            break;
          }
      printf("%d", flag);
    }
    printf("\n");
  }
  return 0;
}
