#include <bits/stdc++.h>
#define INF (1<<29)
#define all(c) (c).begin(),(c).end()
#define pb(c) push_back(c)
using namespace std;
typedef long long ll;
typedef pair<int, int> p;
typedef pair<int, p> pp;

int n, m;
int nn_mx[111][111], mm1_mx[55][55],mm2_mx[55][55],mm3_mx[55][55],mm4_mx[55][55];
bool yes_no = false;
bool flag1 = true;
bool flag = true;
bool flag2 = true;
bool flag3 = true;
bool flag4 = true;
int cnt1, cnt2, cnt3, cnt4;
int cnt;
int ans[2];
bool w, ww, www, wwww;
int ii, jj;
int r, t;

void Rotation(int (*p)[55], int (*p2)[55]){
  for(int i = 0; i < m; i++){
    for(int j = 0; j < m; j++){
      p[i][j] = p2[m-1-j][i];
    }
  }
}

void solve(){
  w = ww = www = wwww = true;
  int ii = -1, jj = -1;
  yes_no = false;
  for(int i = 0; i <= n-m; i++){
    for(int j = 0; j <= n-m; j++){
      flag1 = flag2 = flag3 = flag4 = true;
      cnt1 = cnt2 = cnt3 = cnt4 = 0;
      for(int s = 0; s < m; s++){
        for(int l = 0; l < m; l++){
          // cout << nn_mx[i+s][j+l] << " ";
          if(n > i+s && n > j+l){
            if(flag1 && nn_mx[i+s][j+l] == mm1_mx[s][l]) cnt1++;
            else if(mm1_mx[s][l] != -1){
              flag1 = false;
            }
            if(flag2 && nn_mx[i+s][j+l] == mm2_mx[s][l]) cnt2++;
            else if(mm2_mx[s][l] != -1){
              flag2 = false;
            }
            if(flag3 && nn_mx[i+s][j+l] == mm3_mx[s][l]) cnt3++;
            else if(mm3_mx[s][l] != -1){
              flag3 = false;
            }
            if(flag4 && nn_mx[i+s][j+l] == mm4_mx[s][l]){
              // cout << mm4_mx[s][l] << " hoge ";
              cnt4++;
            }
            else if(mm4_mx[s][l] != -1){
              flag4 = false;
            }
          }
        }
        // cout << endl;
        if(!flag1 && !flag2 && !flag3 && !flag4){
          flag1 = flag2 = flag3 = flag4 = true;
          break;
        }
      }
      if(cnt1 == cnt || cnt2 == cnt || cnt3 == cnt || cnt4 == cnt){
        if(cnt1 == cnt) w = false;
        if(cnt2 == cnt) ww = false;
        if(cnt3 == cnt) www = false;
        if(cnt4 == cnt) wwww = false;
        // cout << cnt1 << endl;
        // cout << cnt2 << endl;
        // cout << cnt3 << endl;
        // cout << cnt4 << endl;
        ii = r = i;
        jj = t = j;
        // cout << ii << " " << jj << "hoge" << endl;
        yes_no = true;
        return;
      }
      else cnt1 = cnt2 = cnt3 = cnt4 = 0;
    }
  }
}

void anss(){
  // cout << ii << endl;
  // cout << " hoge " << endl;
  // cout << r << " " << t << endl;
  if(!w){
    for(int i = r; i < r+m; i++){
      for(int j = t; j < t+m; j++){
        for(int s = 0; s < m; s++){
          for(int l = 0; l < m; l++){
            if(nn_mx[i+s][j+l] == mm1_mx[s][l]){
              ans[1] = i+s+1;
              ans[0] = j+l+1;
              return;
            }
          }
        }
      }
    }
  }else if(!ww){
    for(int i = r; i < r+m; i++){
      for(int j = t; j < t+m; j++){
        for(int s = 0; s < m; s++){
          for(int l = 0; l < m; l++){
            if(nn_mx[i+s][j+l] == mm2_mx[s][l]){
              ans[1] = i+s+1;
              ans[0] = j+l+1;
              return;
            }
          }
        }
      }
    }
  }else if(!www){
    for(int i = r; i < r+m; i++){
      for(int j = t; j < t+m; j++){
        for(int s = 0; s < m; s++){
          for(int l = 0; l < m; l++){
            if(nn_mx[i+s][j+l] == mm3_mx[s][l]){
              // cout << nn_mx[i+s][j+l] << endl;
              // cout << mm3_mx[s][l] << endl;
              ans[1] = i+s+1;
              ans[0] = j+l+1;
              return;
            }
          }
        }
      }
    }
  }else if(!wwww){
    for(int i = r; i < r+m; i++){
      for(int j = t; j < t+m; j++){
        for(int s = 0; s < m; s++){
          for(int l = 0; l < m; l++){
            if(nn_mx[i+s][j+l] == mm4_mx[s][l]){
              // cout << nn_mx[i+s][j+l] << endl;
              // cout << s << " " << l << endl;
              // cout << ii << " " << jj << endl;
              ans[1] = i+s+1;
              ans[0] = j+l+1;
              return;
            }
          }
        }
      }
    }
  }

}

int main(){
  ios::sync_with_stdio(false);

  while(cin >> n >> m && (n||m)){
    cnt1 = cnt2 = cnt3 = cnt4 = 0;
    cnt = 0;
    memset(nn_mx,-2,sizeof(nn_mx));
    memset(mm1_mx,-1,sizeof(mm1_mx));
    memset(mm2_mx,-1,sizeof(mm2_mx));
    memset(mm3_mx,-1,sizeof(mm3_mx));
    memset(mm4_mx,-1,sizeof(mm4_mx));

    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        cin >> nn_mx[i][j];
      }
    }

    for(int i = 0; i < m; i++){
      for(int j = 0; j < m; j++){
        cin >> mm1_mx[i][j];
        if(mm1_mx[i][j] != -1) cnt++;
      }
    }
    Rotation(mm2_mx,mm1_mx);
    Rotation(mm3_mx,mm2_mx);
    Rotation(mm4_mx,mm3_mx);

    solve();

    if(yes_no){
      anss();
      cout << ans[0] << " " << ans[1] << endl;
    }else cout << "NA" << endl;
    // for(int i = ii; i < ii+m; i++){
    //   for(int j = jj; j < jj+m; j++){
    //     cout << nn_mx[i][j] << " ";
    //   }
    //   cout << endl;
    // }
    // for(int s = 0; s < 4; s++){
    //   for(int i = 0; i < m; i++){
    //     for(int j = 0; j < m; j++){
    //       if(s == 0) cout << mm1_mx[i][j] << " ";
    //       if(s == 1) cout << mm2_mx[i][j] << " ";
    //       if(s == 2) cout << mm3_mx[i][j] << " ";
    //       if(s == 3) cout << mm4_mx[i][j] << " ";
    //     }
    //     cout << endl;
    //   }
    //   cout << endl << endl;
    // }
  }
}

Measured memory_bytes: 1304