#include <iostream>
#include <cstdio>
using namespace std;

int n,m,pic[110][111],ed[60][60];
int edb[111][110];
int site;
int num,flag = 0;
int ans,count;

void deb() {
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      cout <<pic[i][j] << " ";
    cout << endl;
  }
  cout << "-------------------"<<endl;
  for(int i=0;i<m;i++) {
    for(int j=0;j<m;j++) {
      printf("%2d ",ed[i][j]);
    }
    cout << endl;
  }
  cout << "---------------"<<endl;
}


void input() {
     
   for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      cin >> pic[i][j];
    }
  }
    
  for(int i=0;i<m;i++) {
    for(int j=0; j<m;j++) {
      cin >> ed[i][j];
    }
  }
}


void rot() {
  int rotf = 0;
  int rotk;
  for(int i=0;i<m;i++){
    rotk = 0;
    for(int j=m-1;j>=0;j--) {
      edb[i][rotk] = ed[j][i];
      rotk++;
    }
  }

  
  for(int i=0;i<m;i++)
    for(int j=0;j<m;j++) {
      ed[i][j] = edb[i][j];
      if(ed[i][j] != -1 && rotf == 0) {
	site = i*m+j;
	num = ed[i][j];
	rotf = 1;
      }
    }

}


void check(int h,int w) {
  int chfla;
  count = 0;
  chfla = 0;
  for(int i=0;i<m;i++) {
    for(int j=0;j<m;j++) {

      if(h+i-site/m >=0 && n > h+i-site/m && w+j-site%m >=0 && w+j-site%m < n) {
	//	printf("ed[%d][%d](%d) == pic[%d][%d](%d)\n",i,j,ed[i][j],h+i-site/m,w+j-site%m,pic[h+i-site/m][w+j-site%m]);
      if(ed[i][j] == -1)count++;
      else if(ed[i][j] == pic[h+i-site/m][w+j-site%m]) count++;
      else {
	chfla = 1;
	break;
      }
      }else break;
    }
    if(chfla == 1) break;
  }
  
  ans = (h)*n+(w);
  //cout << "count = "<<count<<endl;
}

void search() {
  int sefla = 0;
  //cout << num << endl;
  for(int i=0;i<n;i++) {
    for(int j=0; j<n;j++) {
      //  printf("pic[%d][%d](%d) == %d\n",i,j,pic[i][j],num);
      if(pic[i][j] == num) {
	//	printf("pic[%d][%d](%d) => check(%d,%d);\n--------------\n",i,j,pic[i][j] ,i,j);
	check(i,j);
	if(count == m*m) {
	  sefla = 1;
	  break;
	}
      }
    }
    if(sefla == 1) break;
  }
}

  


int main() {
  int ansmax;
  
  while(1) {
    
    cin >> n >> m;
    if(n==0 && m== 0) break;
    input();
    ansmax = n*n+1;
	
    for(int i=0;i<4;i++) {
	rot();
	//deb();    

	search();
	
	if(m*m == count &&( (ans/n) <= ansmax/n) ||((ans%n) < (ansmax%n) && (ans/n) <= ansmax/n)) ansmax  = ans; 
    }
    
    
    if(ansmax != n*n+1) cout << ansmax%n+1 << " " << ansmax/n+1<< endl;
    else cout << "NA" << endl;	
  }
  
  return 0;
}