#include<iostream>

#define N 100
#define M 50

using namespace std;

struct Picture{
  int m;
  int D[M][M];
  void rot90(){
    int newD[M][M];
    for(int i = 0; i < m; ++i){
      for(int j = 0; j < m; ++j){
	newD[i][j] = D[m-j-1][i];
      }
    }
    for(int i = 0; i < m; ++i){
      for(int j = 0; j < m; ++j){
	D[i][j] = newD[i][j];
      }
    }
  }
  void print(){
    cout << " PIC PRINT : " << endl;
    for(int i = 0; i < m; ++i){
      for(int j = 0; j < m; ++j){
	cout << D[i][j] << ' ';
      }
      cout << endl;
    }
  }
  pair<int,int> getFirst(){
    for(int i = 0; i < m; ++i){
      for(int j = 0; j < m; ++j){
	if( D[i][j] > -1 ){
	  return make_pair(i,j);
	}
      }
    }
  }
};


struct Landscape{
  int n;
  int D[N][N];
  bool match(int bi, int bj, const Picture& p){
    for(int i = 0; i < p.m; ++i){
      for(int j = 0; j < p.m; ++j){
	if( D[i+bi][j+bj] != p.D[i][j] && p.D[i][j] != -1 ) return false;
      }
    }
    return true;
  }
};

bool operator<(const pair<int,int> &p1, const pair<int,int> &p2){
  if( p1.first == p2.first ){
    return p1.second < p2.second;
  }else return p1.first < p2.first;
}

int main()
{
  while(true){
    pair<int,int> ans(10000,10000);
    int n,m;
    
    cin >> n >> m;
    if( n == 0 && m == 0 ) break;
    Picture pic;
    Landscape ls;
    
    ls.n = n;
    pic.m = m;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	cin >> ls.D[i][j];
      }
    }
    for(int i = 0; i < m; ++i){
      for(int j = 0; j < m; ++j){
	cin >> pic.D[i][j];
      }
    }
 
    for(int bi = 0; bi <= n - m; ++bi){
      for(int bj = 0; bj <= n - m; ++bj){
	for(int rot = 0; rot < 4; ++rot){
	  if( ls.match( bi, bj, pic ) ){
	    pair<int,int> cand = make_pair(bi,bj);
	    pair<int,int> f = pic.getFirst();
	    cand.first += f.first;
	    cand.second += f.second;
	    ans = min( ans , cand );
	  }
	  //pic.print();
	  pic.rot90();
	}
      }
    }
  end:;
    
    if( ans.first > N )
      cout << "NA" << endl;
    else{
      cout << 1+ans.second << ' ' << 1+ans.first << endl;
    }
  }
  return 0;
}