#include <bits/stdc++.h>
using namespace std;
int n, m;
int r, c;
char tab[455][455];
char pat[455][455];
inline bitset<400> get(const bitset<400> &b, int d) {
  return (b >> d) | (b << (m - d));
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", tab[i]);
  scanf("%d %d", &r, &c);
  for (int i = 0; i < r; i++) scanf("%s", pat[i]);
  bitset<400> res[n];
  bitset<400> is[26][n];
  for (int i = 0; i < n; i++) res[i].set();
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      is[tab[i][j] - 'a'][i][j] = true;
    }
  for (int k = 0; k < r; k++)
    for (int l = 0; l < c; l++) {
      if (pat[k][l] == '?') continue;
      int ch = pat[k][l] - 'a';
      for (int i = 0; i < n; i++) {
        res[i] &= get(is[ch][(i + k) % n], l % m);
      }
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (res[i][j])
        printf("1");
      else
        printf("0");
    }
    puts("");
  }
  return 0;
}
