#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;

int N, M;

vector< vector<int> > rotate(vector< vector<int> > &m){
  vector< vector<int> > res(M, vector<int>(M));
  REP(i, M) REP(j, M) res[i][j] = m[M - j - 1][i];
  return res;
}

P result(int ny, int nx, vector< vector<int> > &m){
  REP(i, M) REP(j, M) if(m[i][j] != -1) return P(j + nx + 1, i + ny + 1);
  return P(-1, -1);
}

P solve(vector< vector<int> > &n, vector< vector<int> > &m){
  REP(ny, N - M + 1){
    REP(nx, N - M + 1){
      REP(i, 4){
        bool f = true;
        REP(y, M) REP(x, M) if(m[y][x] != -1 && n[ny + y][nx + x] != m[y][x]) f = false;
        if(f) return result(ny, nx, m);
        m = rotate(m);
      }
    }
  }
  return P(-1, -1);
}

int main() {
  while(cin >>N >>M && N && M){
    vector< vector<int> > n(N, vector<int>(N)), m(M, vector<int>(M));
    REP(i, N) REP(j, N) cin >>n[i][j];
    REP(i, M) REP(j, M) cin >>m[i][j];
    P res = solve(n, m);
    if(res.first == -1) cout <<"NA" <<endl;
    else cout <<res.first <<" " <<res.second <<endl;
  }
  return 0;
}