#include <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

vector<vector<int>>
rot(vector<vector<int>>&a) {
  const int m = a.size();
  vector<vector<int>> r(m, vector<int>(m));
  rep (i, m) {
    rep (j, m) {
      r[i][j] = a[m-1-j][i];
    }
  }
  return r;
}

int main() {

more:

  int n, m; cin >> n >> m;
  if (!n && !m) return 0;

  int ls[n][n];
  vector<vector<int>> pc(m, vector<int>(m));
  int hs[n][n];

  rep (i, n) {
    rep (j, n) {
      cin >> ls[i][j];
    }
  }

  rep (i, n - m) {
    rep (j, n - m) {
      int sum = 0;
      range (k, i, i + m) {
        range (l, j, j + m) {
          sum += ls[k][l];
        }
      }
      hs[i][j] = sum;
    }
  }

  int hash_of_pc = 0;
  rep (i, m) rep (j, m) {
    int x; cin >> x;
    pc[i][j] = x;
    if (x >= 0) hash_of_pc += x;
  }

  pair<int, int> the = cons(INF, INF);

  rep (_, 4) {
    rep (i, n - m) {
      rep (j, n - m) {
        if (hs[i][j] < hash_of_pc) continue;
        pair<int, int> that = cons(INF, INF);
        range (k, i, i + m) {
          range (l, j, j + m) {
            if (pc[k - i][l - j] < 0) continue;
            if (pc[k - i][l - j] != ls[k][l]) goto fail;
            if (that > cons(k, l)) {
              that = cons(k, l);
            }
          }
        }
        the = min(the, that);

  fail:;

      }
    }
    pc = rot(pc);
  }

  if (car(the) == INF) {
    cout << "NA" << endl;
  } else {
    cout << cdr(the) + 1 << ' ' << car(the) + 1 << endl;
  }

  goto more;
}