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>
std::bitset<410> filters[26][410];
std::bitset<410> result[410];
std::bitset<410> tmp[410];
int n, m, r, c;
std::bitset<410> shifted(std::bitset<410> row, int sh) {
  return (row >> sh) | (row << (m - sh));
}
int main() {
  std::cin >> n >> m;
  std::vector<std::string> table, pattern;
  for (int i = 0; i < n; i++) {
    std::string row;
    std::cin >> row;
    table.push_back(row);
  }
  std::cin >> r >> c;
  for (int i = 0; i < r; i++) {
    std::string row;
    std::cin >> row;
    pattern.push_back(row);
  }
  for (int ch = 0; ch < 26; ch++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        filters[ch][i][j] = (table[i][j] == (ch + 'a'));
        result[i][j] = 1;
      }
    }
  }
  for (int row = 0; row < r; row++) {
    for (int col = 0; col < c; col++) {
      auto ch = pattern[row][col];
      if (ch == '?') {
        continue;
      }
      ch -= 'a';
      for (int i = 0; i < n; i++) {
        result[(n + (i - row) % n) % n] &= shifted(filters[ch][i], col);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      std::cout << (result[i][j] ? '1' : '0');
    }
    std::cout << std::endl;
  }
  return 0;
}
