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 MAXN = (417);
int n, m, N, M;
string a[MAXN], p[MAXN];
void read() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> p[i];
}
bitset<MAXN> dp[MAXN][MAXN];
void kmp(int r1, int r2) {
  string p = ::p[r2], s = "";
  while (p.size() > s.size()) s += a[r1];
  s += s;
  int psz = p.size(), sz = s.size();
  vector<int> f;
  f.assign(sz + 1, 0);
  int j = 0;
  f[0] = 0;
  for (int i = 1; i < psz; i++) {
    while (j >= 0 && p[i] != p[j] && p[j] != '?') {
      if (j >= 1)
        j = f[j - 1];
      else
        j = -1;
    }
    j++;
    f[i] = j;
  }
  j = 0;
  for (int i = 0; i < sz; i++) {
    while (j >= 0 && (p[j] != s[i]) && p[j] != '?')
      if (j >= 1)
        j = f[j - 1];
      else
        j = -1;
    j++;
    if (j == psz) {
      dp[r1][r2][i % m] = 1;
      j = f[j - 1];
    }
  }
}
int ans[MAXN][MAXN];
void solve() {
  for (int rowt = 0; rowt < n; rowt++)
    for (int rowp = 0; rowp < N; rowp++) kmp(rowt, rowp);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      bool ret = 1;
      for (int k = 0; k < N; k++)
        ret &= dp[((i - N + 1 + k) % n + n) % n][k][j];
      ans[((i - N + 1) % n + n) % n][((j - M + 1) % m + m) % m] = ret;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cout << ans[i][j];
      if (j == m - 1) cout << "\n";
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
