#include <iostream>
#define NMAX 100
#define MMAX 50
using namespace std;
int px, py;

void rotate(int pic[MMAX][MMAX], int m){
  int tmp[MMAX][MMAX];
  for (int i=0;i<m;i++)
    for (int j=0;j<m;j++)
      tmp[i][j] = pic[m-j-1][i];
  for (int i=0;i<m;i++)
    for (int j=0;j<m;j++)
      pic[i][j] = tmp[i][j];
}

void searchPoints(int p[MMAX][MMAX], int w[NMAX][NMAX], int n, int m){
  int space=0;
  for (int i=0;i<m;i++)
    if (p[0][i] == -1)
      space++;

  for (int i=0;i<=n-m;i++){
    for (int j=0;j<=n-m;j++){
      bool flag = true;
      for (int k=0;k<m;k++){
        for (int l=0;l<m;l++){
          if (p[k][l] == -1) continue;
          if (p[k][l] != w[i+k][l+j]) flag = false;
        }
      }
      if (flag){
        if ((i < py) || ((i==py) && (j+space < px))){
          px = j + space;
          py = i;
        }
      }
    }
  }
}


int main(){
  int n, m;
  while (cin >> n >> m && (!(n ==0 && m==0))){
    int pic[MMAX][MMAX];
    int window[NMAX][NMAX];
    px = 1000;
    py = 1000;
    for (int i=0;i<n;i++)
      for (int j=0;j<n;j++)
        cin >> window[i][j];
    for (int i=0;i<m;i++)
      for (int j=0;j<m;j++)
        cin >> pic[i][j];
    for (int i=0;i<4;i++){
      searchPoints(pic, window, n, m);
      rotate(pic, m);
    }
    if (px == 1000 && py == 1000)
      cout << "NA" << endl;
    else
      cout << px+1 << ' ' << py+1 << endl;
  }
  return 0;
}