#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> Zahyo;
typedef pair<Zahyo,int> Kirehasi;
int picture[120][120];
int ki[4][60][60];
int firstx[4];
int firsty[4];
int main(){
  int n,m;
  while(1){
    int kirehasipos=0;
    memset(picture,-1,sizeof(picture));
    memset(ki,-1,sizeof(ki));
    cin>>n>>m;
    if(n==0&&m==0)break;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin>>picture[i][j];
      }
    }
    for(int i=0;i<m;i++){
      for(int j=0;j<m;j++){
	cin>>ki[0][i][j];
	ki[1][m-1-j][i]=ki[0][i][j];
	ki[2][m-1-i][m-1-j]=ki[0][i][j];
	ki[3][j][m-1-i]=ki[0][i][j];
      }
    }	 
    
    for(int i=0;i<4;i++){
      bool a=true;
      for(int j=0;j<m;j++){
	for(int k=0;k<m;k++){
	  if(a==true&&ki[i][j][k]!=-1){
	    firstx[i]=k;
	    firsty[i]=j;
	    a=false;
	  }
	  //printf("%2d",ki[i][j][k]);
	}
	//cout<<endl;
      }
      //cout<<firsty[i]<<" "<<firstx[i]<<endl;
    }
    
    int ansx=200,ansy=200;
    for(int i=0;i<4;i++){
      for(int j=0;j<=n-m;j++){
	for(int k=0;k<=n-m;k++){
	  bool check=true;
	  for(int l=0;l<m;l++){
	    for(int o=0;o<m;o++){
	      if(ki[i][l][o]!=-1&&picture[j+l][k+o]!=ki[i][l][o]){
		//cout<<i<<" "<<j<<" "<<k<<" "<<l<<" "<<o<<endl;
		check=false;
	      }
	    }
	  }
	  if(check&&(ansy>j+firsty[i]+1||(ansy==j+firsty[i]+1&&ansx>k+firstx[i]+1))){
	    //cout<<i<<" "<<j<<" "<<k<<endl;
	    ansy=j+firsty[i]+1;
	    ansx=k+firstx[i]+1;
	  }
	}
      }
    }
    if(ansx!=200||ansy!=200){
      cout<<ansx<<" "<<ansy<<endl;
    }
    else{
      cout<<"NA"<<endl;
    }
  }
}