#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)


//(0,0)??????(n,n)????????????????????¢
void matrix_right_rotation(vector<vector<int>> &data, int n){
    vector<vector<int>> tmp = data;
    rep(i,n){
        rep(j,n){
            data[i][j] = tmp[n-j-1][i];
        }
    }
}
int main(){
    int n,m;
    while(cin>>n>>m&&(n||m)){
        vector<vector<int>> v(n,vector<int>(n));
        vector<vector<vector<int>>> p(4,vector<vector<int>>(m,vector<int>(m)));
        rep(i,n)rep(j,n)cin>>v[i][j];
        rep(i,m)rep(j,m)cin>>p[0][i][j];
        for(int k=1;k<4;k++){
            rep(i,m)rep(j,m)p[k][i][j] = p[k-1][i][j];
            matrix_right_rotation(p[k],m);
        }
        
        int y=INF,x=INF;
        rep(i,n-m+1){
            rep(j,n-m+1){
                rep(k,4){
                    bool f = true;
                    for(int ii=i;ii<i+m;ii++){
                        for(int jj=j;jj<j+m;jj++){
                            if(p[k][ii-i][jj-j]==-1)continue;
                            if(p[k][ii-i][jj-j]!=v[ii][jj])f = false;
                        }
                    }
                    if(f){
                        for(int ii=i;ii<i+m;ii++){
                            for(int jj=j;jj<j+m;jj++){
                                if(p[k][ii-i][jj-j]!=-1){
                                    if(ii<y || ii==y&&jj<x)y = ii, x = jj;
                                }
                            }
                        }
                    }
                }
            }
        }
        if(y==INF)cout<<"NA"<<endl;
        else cout<<x+1<<" "<<y+1<<endl;
    }
}