#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int pic[100][100];
int piece[4][50][50];
int n, m;

bool ck(int sy, int sx, int d){
  rep(i, m) rep(j, m){
    if(piece[d][i][j] == -1) continue;
    //    printf("%d %d\n", pic[sy+i][sx+j], piece[d][i][j]);
    if(pic[sy+i][sx+j] != piece[d][i][j]) return false;
  }
  return true;
}

int main(){
  while(scanf("%d%d", &n, &m) && n+m){
    rep(i, n) rep(j, n) scanf("%d", &pic[i][j]);
    rep(i, m) rep(j, m) scanf("%d", &piece[0][i][j]);

    REP(k, 1, 4){
      rep(i, m) rep(j, m) piece[k][j][m-i-1] = piece[k-1][i][j];
    }

    /*    rep(k, 4){
      rep(i, m){
	rep(j, m) printf("%3d", piece[k][i][j]);
	puts("");
      }
      puts("");
      }*/

    rep(i, n-m+1){
      rep(j, n-m+1){
	rep(k, 4){
	  //	  printf("%d %d %d\n", i, j, k);
	  if(ck(i, j, k)){
	    rep(l, m) rep(h, m) if(piece[k][l][h] != -1){
	      printf("%d %d\n", j+h+1, i+l+1);
	      goto end;
	    }
	  }
	}
      }
    }
    puts("NA");
  end:;
  }
  return 0;
}