#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
int B=1000000;
int N,M;
int dat[50][50];
int fld[100][100];
void rotate(){
      int tmp[50][50];
      REP(i,M)REP(j,M){
            tmp[j][i]=dat[i][M-j-1];
      }
      REP(i,M)REP(j,M)dat[j][i]=tmp[j][i];
}
int main(){
      int n,m;
      while(cin>>N>>M&&(N||M)){
            vector<P> ans;
            REP(i,N)REP(j,N)cin>>fld[j][i];
            REP(i,M)REP(j,M)cin>>dat[j][i];
            REP(times,4){
                  //REP(x,M)REP(y,M)printf("%2d%c",dat[y][x],y==M-1?'\n':' ');
                  //cout<<endl;
                  //cout<<times<<endl;
                  REP(i,N-M+1){
                        REP(j,N-M+1){
                              bool f=true;
                              REP(x,M)REP(y,M){
                                    if(dat[x][y]==-1)continue;
                                    if(dat[x][y]!=fld[x+i][y+j])f=false;
                              }
                              if(f){
                                    //REP(x,N)REP(y,N)printf("%d%c",fld[y][x],y==N-1?'\n':' ');
                                    //REP(x,M)REP(y,M)printf("%2d%c",dat[y][x],y==M-1?'\n':' ');
                                    REP(y,M)REP(x,M)if(dat[x][y]!=-1)ans.PB(P(y+j+1,x+i+1));
                              }
                        }
                  }
                  rotate();
            }
            sort(ALL(ans));
            if(ans.size()==0){
                  cout<<"NA"<<endl;
            }else{
                  cout<<ans[0].second<<" "<<ans[0].first<<endl;
            }
      }
}