#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,m,t[4][100][100],s[100][100];
	while(cin>>n>>m,n||m){
		rep(i,n)
		rep(j,n)
		cin>>s[i][j];
		rep(i,m)
		rep(j,m)
		cin>>t[0][i][j];
		rep(i,3){
			rep(y,m){
				rep(x,m){
					t[i+1][y][m-x-1]=t[i][x][y];
				}
			}
		}
		rep(i,4){
			rep(y1,n-m){
				rep(x1,n-m+1){
					rep(y2,m+1){
						rep(x2,m){
							if(t[i][y2][x2]!=-1&&s[y1+y2][x1+x2]!=t[i][y2][x2])
								goto hh;
							if(x2==m-1&&y2==m-1){
								//cout<<"   "<<x1<<' '<<y1<<endl;
								rep(y2,m)
								rep(x2,m)
								if(t[i][y2][x2]!=-1){
									cout<<x2+x1+1<<' '<<y2+y1+1<<endl;
									goto gg;
								}
							}
						}
					}
					hh:;
				}
			}
		}
		cout<<"NA"<<endl;
		gg:;
	}
	return 0;
}