#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
inline int in(){ int x; scanf("%d", &x); return x; }

int main() {
  int field[128][128];
  int piece[4][64][64];
  int N, M;
  while (N = in(), M = in()) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        field[i][j] = in();
      }
    }
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < M; j++) {
        piece[0][i][j] = in();
      }
    }
    for (int r = 1; r < 4; r++) {
      for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
          piece[r][i][j] = piece[r - 1][M - j - 1][i];
        }
      }
    }
    vector<duo> ps;
    for (int i = 0; i <= N - M; i++) {
      for (int j = 0; j <= N - M; j++) {
        for (int r = 0; r < 4; r++) {
          bool ok = true;
          for (int k = 0; k < M; k++) {
            for (int l = 0; l < M; l++) {
              if (piece[r][k][l] == -1) continue;
              if (piece[r][k][l] == field[i + k][j + l]) continue;
              ok = false;
              goto END1;
            }
          }
END1:;
          if (ok){
            for (int k = 0; k < M; k++){
              for (int l = 0; l < M; l++){
                if (piece[r][k][l] == -1) continue;
                ps.emplace_back(i + k + 1, j + l + 1);
                goto END2;
              }
            }
END2:;
          }
        }
      }
    }
    sort(begin(ps), end(ps));
    if (ps.size()) printf("%d %d\n", get<1>(ps[0]), get<0>(ps[0]));
    else puts("NA");
  }
  return 0;
}