#include <bits/stdc++.h>
using namespace std;
int lps[2001][2001];
string map1[2001], map2[2001];
void computeLps(int t) {
  lps[t][0] = 0;
  int k = 0;
  for (int i = 1; i < map1[t].size(); ++i) {
    while (k > 0 && map1[t][k] != map1[t][i]) k = lps[t][k - 1];
    if (map1[t][k] == map1[t][i]) ++k;
    lps[t][i] = k;
  }
}
bool kmp(int r, int t) {
  int k = 0;
  for (int i = 0; i < map2[r].size(); ++i) {
    while (k > 0 && map2[r][i] != map1[t][k]) k = lps[t][k - 1];
    if (map2[r][i] == map1[t][k]) ++k;
    if (k == map1[t].size()) return true;
  }
  return false;
}
int findKmp(int r, int t) {
  int k = 0;
  for (int i = 0; i < map2[r].size(); ++i) {
    while (k > 0 && map2[r][i] != map1[t][k]) k = lps[t][k - 1];
    if (map2[r][i] == map1[t][k]) ++k;
    if (k == map1[t].size()) return i - k + 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> map1[i];
    computeLps(i);
  }
  for (int i = 0; i < m; ++i) cin >> map2[i];
  for (int j = 0; j < n; ++j) {
    bool flag = 1;
    for (int k = j, i = 0; i < m; ++k, ++i) {
      if (!kmp(i, k)) {
        flag = false;
        break;
      }
    }
    if (flag) {
      printf("%d ", j + 1);
      int col = INT_MIN;
      for (int k = j, i = 0; i < m; ++k, ++i) {
        int tmp = findKmp(i, k);
        col = max(col, tmp);
      }
      printf("%d\n", col + 1);
      return 0;
    }
  }
}
