// Original C++ solution (slower):
#include<iostream>



using namespace std;

#define rep(i, n) for ( int i = 0; i < n; i++ )

#define MAX 200

#define INFTY (1<<21)

int n, m, T[MAX][MAX], P[MAX][MAX];



void valid(int sx, int sy, int &lx, int &ly ){

    int ax = -1, ay;

    rep(y, m) rep(x, m){

	if ( P[x][y] == -1 ) continue;

	if ( P[x][y] != T[sx+x][sy+y] ) return;

	if ( ax == -1 ) {ay = y; ax = x;}

    }

    if ( ay < ly || (ay == ly && ax < lx) ) {ly = sy+ay; lx = sx+ax; }

}



bool rotate(int sx, int sy){

    int tmp[MAX][MAX];

    int ly = INFTY, lx;

    rep(r, 4){

	valid(sx, sy, lx, ly);

	rep(y, m) rep(x, m) tmp[x][y] = P[x][y];

	rep(y, m) rep(x, m) P[y][m-x-1] = tmp[x][y];

    }

    if ( ly == INFTY ) return false;

    cout << lx+1 << " " << ly+1 << endl;

    return true;

}



void compute(){

    rep(y, n-m+1) rep(x, n-m+1) if ( rotate(x, y) ) return;

    cout << "NA" << endl;

}



main(){

    while( cin >> n >> m && n ){

	rep(y, n) rep(x, n) cin >> T[x][y];

	rep(y, m) rep(x, m) cin >> P[x][y];

	compute();

    }

}

// Optimized solution to the same problem (faster):
#include<cstdio>



#define rep(i, n) for ( int i = 0; i < n; i++ )

#define MAX 200

#define INFTY (1<<21)

int n, m, T[MAX][MAX], P[MAX][MAX];



void valid(int sx, int sy, int &lx, int &ly ){

    int ax = -1, ay;

    rep(y, m) rep(x, m){

	if ( P[x][y] == -1 ) continue;

	if ( P[x][y] != T[sx+x][sy+y] ) return;

	if ( ax == -1 ) {ay = y; ax = x;}

    }

    if ( ay < ly || (ay == ly && ax < lx) ) {ly = sy+ay; lx = sx+ax; }

}



bool rotate(int sx, int sy){

    int tmp[MAX][MAX];

    int ly = INFTY, lx;

    rep(r, 4){

	valid(sx, sy, lx, ly);

	rep(y, m) rep(x, m) tmp[x][y] = P[x][y];

	rep(y, m) rep(x, m) P[y][m-x-1] = tmp[x][y];

    }

    if ( ly == INFTY ) return false;

    printf("%d %d\n", lx+1, ly+1);

    return true;

}



void compute(){

    rep(y, n-m+1) rep(x, n-m+1) if ( rotate(x, y) ) return;

    printf("NA\n");

}



main(){

    while( scanf("%d %d", &n, &m) && n ){

	rep(y, n) rep(x, n) scanf("%d", &T[x][y]);

	rep(y, m) rep(x, m) scanf("%d", &P[x][y]);

	compute();

    }

}

// Fastest known solution for this problem:
#include <iostream>

#include <climits>

using namespace std;



int n, m;

int ansX, ansY;

int t[102][102], s[52][52], tmp[52][52];



void rotate(){

  for(int i = 0; i < m; i++){

    for(int j = 0; j < m; j++){

      tmp[i][j] = s[i][j];

    }

  }



  for(int i = 0; i < m; i++){

    for(int j = 0; j < m; j++){

      s[j][m - i - 1] = tmp[i][j];

    }

  }

}



void update(int sx, int sy){

  for(int i = 0; i < m; i++){

    for(int j = 0; j < m; j++){

      if(s[i][j] != -1){

        int x = sx + j;

        int y = sy + i;



        if(y < ansY || y == ansY && x < ansX){

          ansX = x;

          ansY = y;

          return;

        }

      }

    }

  }

}



bool check(int sx, int sy){

  for(int i = sy; i < sy + m; i++){

    for(int j = sx; j < sx + m; j++){

      if(s[i - sy][j - sx] == -1) continue;

      if(s[i - sy][j - sx] != t[i][j]){

        return false;

      }

    }

  }



  return true;

}



void solve(){

  for(int sx = 0; sx <= n - m; sx++){

    for(int sy = 0; sy <= n - m; sy++){

      for(int i = 0; i < 4; i++){

        if(check(sx, sy)){

          update(sx, sy);

        }

        rotate();

      }

    }

  }



  if(ansX == INT_MAX){

    cout << "NA\n";

  }

  else{

    cout << ansX + 1 << " " << ansY + 1 << endl;

  }

}



void show(){

  for(int i = 0; i < m; i++){

    for(int j =0; j < m; j++){

      printf("%3d", s[i][j]);

    }

    cout<<endl;

  }

  cout<<"--\n";

}



int main(){

  while(cin >> n >> m, n || m){

    ansX = INT_MAX;

    ansY = INT_MAX;



    for(int i = 0; i < n; i++){

      for(int j = 0; j < n; j++){

        cin >> t[i][j];

      }

    }



    for(int i = 0; i < m; i++){

      for(int j = 0; j < m; j++){

        cin >> s[i][j];

      }

    }



    solve();

  }

}