#include <iostream>
#include <vector>
using namespace std;


int pattern(const vector<vector<char> >& P, const vector<vector<char> >& M);


int main() {
  int n1, m1;
  while (cin >> n1 >> m1) {
    vector<vector<char> > P(n1, vector<char>(m1));
    for (int i = 0; i < n1; ++i)
      for (int j = 0; j < m1; ++j) cin >> P[i][j];
    int n2, m2;
    cin >> n2 >> m2;
    vector<vector<char> > M(n2, vector<char>(m2));
    for (int i = 0; i < n2; ++i)
      for (int j = 0; j < m2; ++j) cin >> M[i][j];
    cout << pattern(P, M) << endl;
  }
}
