#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;
int pic[51][51];
int n,m;

vector< vector<int> > rotate(int a){
    vector< vector<int> > ret(m,vector<int>(m));
    if(a == 0){
	REP(i,m)REP(j,m){
	    ret[i][j] = pic[i][j];
	}
    }else if(a == 3){
	REP(i,m)REP(j,m){
	    ret[i][j] = pic[m-1-j][i];
	}
    }else if(a == 2){
	REP(i,m)REP(j,m){
	    ret[i][j] = pic[m-1-i][m-1-j];
	}
    }else if(a == 1){
	REP(i,m)REP(j,m){
	    ret[i][j] = pic[j][m-1-i];
	}
    }
    return ret;
}

int main(){
    while(true){
	int map[101][101];
	cin >> n >> m;
	if(n==0&&m==0) break;
	memset(map,-1,sizeof(map));
	memset(pic,-1,sizeof(pic));
	REP(i,n)REP(j,n){
	    cin >> map[i][j];
	}
	REP(i,m)REP(j,m){
	    cin >> pic[i][j];
	}
	bool flg = true;
	REP(a,4){
	    
	    vector< vector<int> > p = rotate(a);
	    for(int i=0;i+m<=n;i++){
		for(int j=0;j+m<=n;j++){
		    flg = true;
		    int il,ik;
		    il = -1;
		    ik = -1;
		    REP(k,m)REP(l,m){
			if(p[k][l]!=-1&&p[k][l]!=map[i+k][j+l]){
			    flg = false;
			    break;
			}else if(p[k][l]==map[i+k][j+l]&&il == -1 && ik == -1){
			    il = j+l+1;
			    ik = i+k+1;
			}
		    }
		    if(flg){
			cout << il << " " << ik<<endl;
			break;
		    }
		}
		if(flg){
		    break;
		}
	    }
	    if(flg) break;
	}
	if(!flg) cout << "NA" << endl;
    }
    return 0;
}