#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
const int INF = 1 << 30;
typedef pair < int , int > Pi;
int n, m, mas[101][101], hoge[4][51][51];

bool isfind( const int& k, const int& y, const int& x, Pi& exitp)
{
  for(int i = 0 ; i < m ; i++ ){
    for(int j = 0 ; j < m ; j++ ){
      if( hoge[k][i][j] == -1) continue;
      if( mas[i + y][j + x] != hoge[k][i][j]) return false;
      if(exitp == Pi(-1,-1)) exitp = Pi(i + y + 1,j + x + 1);
    }
  }
  return true;
}

Pi solve()
{

  for(int i = 0 ; i <= n - m ; i++ ){
    for(int j = 0 ; j <= n - m ; j++ ){
      for(int k = 0 ; k < 4 ; k++ ){
        Pi p = Pi( -1, -1);
        if(isfind( k, i, j, p)) return p;
      }
    }
  }
  return Pi( INF, -1);
}
int main()
{
  while(cin >> n >> m, n){
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < n ; j++ ){
        cin >> mas[i][j];
      }
    }
    for(int i = 0 ; i < m ; i++ ){
      for(int j = 0 ; j < m ; j++ ){
        cin >> hoge[0][i][j];
      }
    }

    for(int k = 1 ; k < 4 ; k++ ){
      for(int i = 0 ; i < m ; i++ ){
        for(int j = 0 ; j < m ; j++ ){
          hoge[k][j][m - i - 1] = hoge[k - 1][i][j];
        }
      }
    }

    Pi pos = solve();
    if(pos.first == INF) cout << "NA" << endl;
    else cout << pos.second << " " << pos.first << endl;
  }
  return 0;
}