#include<iostream>
using namespace std;

int win[100][100], pic[50][50], n, m;

bool match(int sx, int sy)
{
  bool b[] = {true, true, true, true};
  for(int y = 0; y < m; y++)
  {
    for(int x = 0; x < m; x++)
    {
      int t[] = {pic[y][x], pic[x][m - y - 1], pic[m - x - 1][y], pic[m - y - 1][m - x - 1]};
      for(int i = 0; i < 4; i++)
        if(t[i] != -1 && win[sy + y][sx + x] != t[i])
          b[i] = false;
    }
  }
  bool a = false;
  for(auto v : b)
    a |= v;
  return a;
}

int main()
{
loop:
  cin >> n >> m;
  if(!n)
    return 0;
  int tmp;
  for(int y = 0; y < n; y++)
  {
    for(int x = 0; x < n; x++)
    {
      cin >> tmp;
      win[y][x] = tmp;
    }
  }
  for(int y = 0; y < m; y++)
  {
    for(int x = 0; x < m; x++)
    {
      cin >> tmp;
      pic[y][x] = tmp;
    }
  }

  for(int y = 0; y <= n - m; y++)
  {
    for(int x = 0; x <= n - m; x++)
    {
      if(match(x, y))
      {
        cout << x + 1 << " " << y + 1 << endl;
        goto loop;
      }
    }
  }
  cout << "NA" << endl;
  goto loop;
}