#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int n, m;
int ba[100][100];
int bi[50][50];

void rotate() {
  int res[50][50];
  REP(y, m)
    REP(x, m)
      res[y][m-x-1] = bi[x][y];
  memcpy(bi, res, sizeof(res));
}

int main() {
  while(cin >> n >> m, n+m) {
    REP(y,n)
      REP(x,n)
      cin >> ba[x][y];
    REP(y,m)
      REP(x,m)
      cin >> bi[x][y];
    int sx, sy;
    bool f;
    REP(i,4) {
      // REP(y,m) {
      //   REP(x,m)
      //     cout << bi[x][y] << " ";
      //   cout << endl;
      // }
      REP(y,n-m+1) {
        REP(x,n-m+1) {
          f = 1;
          sx = -1;
          REP(y1,m) {
            REP(x1,m) {
              int xx = x + x1;
              int yy = y + y1;
              if (bi[x1][y1] == -1) continue;
              if (sx<0) sx = xx, sy = yy;
              if (ba[xx][yy] != bi[x1][y1])
                f = 0;
            }
          }
          if (f) break;
        }
        if (f) break;
      }
      if (f) break;
      rotate();
    }
    if (f) {
      printf("%d %d\n", sx+1, sy+1);
    } else
      cout << "NA" << endl;
  }
}