#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int view[100][100], pict[50][50], temp[50][50];

int main() {
  for (;;) {
    int n, m;
    cin >> n >> m;
    if (!n && !m) return 0;
    for (int y = 0; y < n; y++)
      for (int x = 0; x < n; x++)
        cin >> view[x][y];
    for (int y = 0; y < m; y++)
      for (int x = 0; x < m; x++)
        cin >> pict[x][y];
    for (int y = 0; y < n-m; y++) {
      bool flag = false;
      int mx = 100;
      for (int x = 0; x < n-m; x++)
        for (int z = 0; z < 4; z++) {
          for (int j = 0; j < m; j++)
            for (int i = 0; i < m; i++)
              temp[i][j] = pict[j][m-i-1];
          for (int j = 0; j < m; j++)
            for (int i = 0; i < m; i++)
              pict[i][j] = temp[i][j];
          for (int j = 0; j < m; j++)
            for (int i = 0; i < m; i++)
              if (pict[i][j] != -1 && pict[i][j] != view[i+x][j+y])
                goto fail;
          flag = true;
          for (int i = 0; i < m; i++)
            if (pict[i][0] != -1) {
              mx = min(mx, i+x);
              break;
            }
        fail:;
        }
      if (flag) {
        cout << mx+1 << ' ' << y+1 << endl;
        goto finish;
      }
    }
    cout << "NA" << endl;
  finish:;
  }
}