#include<iostream>
#include<cassert>
#include<ctime>
#include<climits>
#include<queue>
#include<fstream>
#include<deque>
#include<iomanip>
#include<list>
#include<stack>
#include<sstream>
#include<string>
#include<cctype>
#include<cstdio>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-10
#define F first
#define S second
#define all(n) n.begin(),n.end()
#define pb push_back
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define INF (1<<27)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
int n,m;
int nmap[102][102],map4[52][52][4];
int t_ansx,t_ansy;

void make_map(){
  //cout << "90---" << endl;
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      map4[i][j][1] = map4[j][(m-1)-i][0];
      //cout << map_90[i][j] << " ";
    }
    //cout << endl;
  }
  //cout << endl;

  //cout << "180---" << endl;
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      map4[i][j][2] = map4[(m-1)-i][(m-1)-j][0];
      //cout << map_180[i][j] << " ";
    }
    //cout << endl;
  }
  //cout << endl;

  //cout << "270---" << endl;
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      map4[i][j][3] = map4[(m-1)-j][i][3];
      //cout << map_270[i][j] << " ";
    }
    //cout << endl;
  }
  //cout << endl;

 

}


bool research(int x,int y,int dir){
  assert(0<= dir && dir < 4);
  //cout << "res! x = "<< x << ",y = " << y << ",dir = " << dir << endl;  
  int ansx,ansy;
  bool first = true;
  int nx,ny;
  if(dir == 0)nx = x,ny = y;
  else if(dir == 1)nx =x,ny = y-(m-1);
  else if(dir == 2)nx = x-(m-1),ny = y-(m-1);
  else if(dir == 3)nx = x-(m-1),ny =y;


  ansx = ansy = INT_MAX;
  rep(i,m){
    rep(j,m){
      if((map4[i][j][dir] == -1) || (map4[i][j][dir] == -1) ||( map4[i][j][dir] == -1) ||(map4[i][j][dir] == -1))continue;      
      //if(!(0<= nx+j && nx+j <m && 0<= ny+i && ny+i <m))return false;

      if(nmap[ny+i][nx+j] != map4[i][j][dir] && nmap[ny+i][nx+j] != -1){
	return false;
      }      
      else if(first){
	ansx = x+j,ansy = y+i;
	first = false;
      }
    }   
  }
      

  // cout << ansx+1 << " " << ansy+1 << endl;
  if(ansy < t_ansy){
    t_ansx = ansx;
    t_ansy = ansy;
  }
  else if(ansy == t_ansy){
    if(ansx < t_ansx){
      t_ansx = ansx;
      t_ansy = ansy;
    }
  }

 

  return true;
}


int main(){
  while(true){
    cin >> n >> m;
    cerr <<  n << " " << m << endl;
    if(n+m == 0)break;
    rep(i,n){
      rep(j,n){
	cin >> nmap[i][j];
	cerr << nmap[i][j] << " ";
      }
      cerr << endl;
    }
    t_ansx = t_ansy = INT_MAX;

  
    rep(i,m){
      rep(j,m){
	cin >> map4[i][j][0];	
	cerr << map4[i][j][0] << " ";
      }
      cerr << endl;
    }
    cerr << endl;
   

    make_map();


    bool fin = false;
    rep(i,n){
      rep(j,n){
	if(nmap[i][j] != map4[0][0][0])continue;
	rep(k,4){
	  if(research(j,i,k)){
	   
	    //cout << j+1 << " " << i+1 << endl;
	    fin = true;
	    //break;
	  }
	 
	}
	//if(fin)break;
      }
      //if(fin)break;
    }

    if(!fin)cout << "NA" << endl;
    else cout << t_ansx+1 << " " << t_ansy +1 << endl;

  }
return 0;
}