#include <iostream>
using namespace std;

int n, m;
int w[100][100];
int p[50][50];
int b;
bool input() {
  cin >> n >> m;
  if (!n && !m) {
    return false;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> w[i][j];
    }
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> p[i][j];
    }
  }
  return true;
}

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

bool check(int r, int c) {
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      if (p[i][j] == -1) {
        continue;
      }
      if (p[i][j] != w[r + i][c + j]) {
        return false;
      }
    }
  }
  return true;
}

void solve() {
  b = n * n;
  for (int i = 0; i < 4; ++i) {
    bool found = false;
    int dr = -1;
    int dc = -1;
    for (int r = 0; r < m; ++r) {
      for (int c = 0; c < m; ++c) {
        if (p[r][c] != -1) {
          dr = r;
          dc = c;
          found = true;
          break;
        }
      }
      if (found) {
        break;
      }
    }

    for (int r = 0; r < n - m; ++r) {
      if ((r + dr) * n > b) {
        continue;
      }
      for (int c = 0; c < n - m; ++c) {
        int bb = (r + dr) * n + c + dc;
        if (bb > b) {
          continue;
        }
        if (check(r, c)) {
          if (b > bb) {
            b = bb;
          }
          break;
        }
      }
    }
    rotate();
  }
  if (b == n * n) {
    cout << "NA" << endl;
    return;
  } else {
    cout << b % n + 1 << " " << b / n + 1 << endl;
  }
}

int main() {
  while (input()) {
    solve();
  }
  return 0;
}