#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

int w[102][102], p0[102][102], p90[102][102], p180[102][102], p270[102][102], n, m, res[2];

void solve(int y, int x, int num) {
  int xt, yt;
  xt = 1000;
  
  for(int i = y; i < y+m; i++) {
    for(int j = x; j < x+m; j++) {
      if(num == 0) {
        if(p0[i-y][j-x] != -1 && xt == 1000) {
          xt=j; yt=i;
        }
        if(p0[i-y][j-x] != -1 && p0[i-y][j-x] != w[i][j]) {
          return;
        }
      }
      if(num == 90) {
        if(p90[i-y][j-x] != -1 && xt == 1000) {
          xt=j; yt=i;
        }
        if(p90[i-y][j-x] != -1 && p90[i-y][j-x] != w[i][j]) {
          return;
        }
      }
      if(num == 180) {
        if(p180[i-y][j-x] != -1 && xt == 1000) {
          xt=j; yt=i;
        }
        if(p180[i-y][j-x] != -1 && p180[i-y][j-x] != w[i][j]) {
          return;
        }
      }
      if(num == 270) {
        if(p270[i-y][j-x] != -1 && xt == 1000) {
          xt=j; yt=i;
        }
        if(p270[i-y][j-x] != -1 && p270[i-y][j-x] != w[i][j]) {
          return;
        }
      }
    }
  }

  if(res[0] > xt+1) {
    res[0] = xt+1;
    res[1] = yt+1;
  }else if(res[0] == xt+1) {
    if(res[1] > yt+1) {
      res[0] = xt+1;
      res[1] = yt+1;
    }
  }
}

int main() {
  while(cin >> n >> m, n) {
    res[0] = 1000;
    res[1] = 1000;
    rep(i, n) {
      rep(j, n) {
        cin >> w[i][j];
      }
    }
    rep(i, m) {
      rep(j, m) {
        int t;
        cin >> t;
        p0[i][j] = t;
        p90[j][m-1-i] = t;
        p180[m-1-i][m-1-j] = t;
        p270[m-1-j][i] = t;
      }
    }

    for(int i=0; i+m <= n; i++) {
      for(int j=0; j+m <= n; j++) {
        solve(i, j, 0);
        solve(i, j, 90);
        solve(i, j, 270);
        solve(i, j, 180);
      }
    }

    if(res[0] == 1000)
      cout << "NA" << endl;
    else
      cout << res[1] << " " << res[0] << endl;
  }
        
  return 0;
}