// Original C++ solution (slower):
#include <cstdio>

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <set>

#include <queue>

#include <cstring>



using namespace std;



#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)

#define rep(i,n) reep(i, 0, n) 



typedef vector<int> vi;

typedef vector<vi> vvi;

typedef pair<int,int> pii;



pii fit(const vvi& window, const vvi& pic, int y, int x)

{

	int m = pic.size();

	pii ans(-1, -1);

	rep(i, m) rep(j, m){

		if(pic[i][j] == -1)

			continue;

		

		if(window[y+i][x+j] != pic[i][j]){

			return pii(-1, -1);

		}else if(ans.first == -1)

			ans = pii(y+i, x+j);

	}

	return ans;

}



void rotate(vvi& p)

{

	int m = p.size();

	vvi next(m, vi(m));

	rep(i, m) rep(j, m)

		next[i][j] = p[m-j-1][i];

	

	p.swap(next);

}



int main()

{

	int n, m;

	while(scanf("%d%d", &n, &m), n){

		vvi window(n, vi(n));

		rep(i, n) rep(j, n)

			scanf("%d", &window[i][j]);

		

		vvi pic(m, vi(m));

		rep(i, m) rep(j, m)

			scanf("%d", &pic[i][j]);

		

		pii ans(-1, -1);

		rep(i, n-m+1) rep(j, n-m+1){

			rep(k, 4){

				ans = fit(window, pic, i, j);

				if(ans.first != -1){

					i=n-m+1;

					j=n-m+1;

					break;

				}

				rotate(pic);

			}

		}

		

		if(ans.first == -1)

			puts("NA");

		else

			printf("%d %d\n", ans.second+1, ans.first+1);

	}

	

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <set>

#include <queue>

#include <cstring>



using namespace std;



#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)

#define rep(i,n) reep(i, 0, n) 



typedef vector<int> vi;

typedef vector<vi> vvi;

typedef pair<int,int> pii;



int m;



pii fit(const int window[][100], const int pic[][50], int y, int x)

{

	pii ans(-1, -1);

	rep(i, m) rep(j, m){

		if(pic[i][j] == -1)

			continue;

		

		if(window[y+i][x+j] != pic[i][j]){

			return pii(-1, -1);

		}else if(ans.first == -1)

			ans = pii(y+i, x+j);

	}

	return ans;

}



void rotate(int p[][50])

{

	int next[50][50];

	rep(i, m) rep(j, m)

		next[i][j] = p[m-j-1][i];

	

	rep(i, m) rep(j, m)

		p[i][j] = next[i][j];

}



int main()

{

	int n;

	while(scanf("%d%d", &n, &m), n){

		int window[100][100];

		rep(i, n) rep(j, n)

			scanf("%d", &window[i][j]);

		

		int pic[50][50];

		rep(i, m) rep(j, m)

			scanf("%d", &pic[i][j]);

		

		pii ans(-1, -1);

		rep(i, n-m+1) rep(j, n-m+1){

			rep(k, 4){

				ans = fit(window, pic, i, j);

				if(ans.first != -1){

					i=n-m+1;

					j=n-m+1;

					break;

				}

				rotate(pic);

			}

		}

		

		if(ans.first == -1)

			puts("NA");

		else

			printf("%d %d\n", ans.second+1, ans.first+1);

	}

	

	return 0;

}

// Fastest known solution for this problem:
#include <iostream>

#include <climits>

using namespace std;



int n, m;

int ansX, ansY;

int t[102][102], s[52][52], tmp[52][52];



void rotate(){

  for(int i = 0; i < m; i++){

    for(int j = 0; j < m; j++){

      tmp[i][j] = s[i][j];

    }

  }



  for(int i = 0; i < m; i++){

    for(int j = 0; j < m; j++){

      s[j][m - i - 1] = tmp[i][j];

    }

  }

}



void update(int sx, int sy){

  for(int i = 0; i < m; i++){

    for(int j = 0; j < m; j++){

      if(s[i][j] != -1){

        int x = sx + j;

        int y = sy + i;



        if(y < ansY || y == ansY && x < ansX){

          ansX = x;

          ansY = y;

          return;

        }

      }

    }

  }

}



bool check(int sx, int sy){

  for(int i = sy; i < sy + m; i++){

    for(int j = sx; j < sx + m; j++){

      if(s[i - sy][j - sx] == -1) continue;

      if(s[i - sy][j - sx] != t[i][j]){

        return false;

      }

    }

  }



  return true;

}



void solve(){

  for(int sx = 0; sx <= n - m; sx++){

    for(int sy = 0; sy <= n - m; sy++){

      for(int i = 0; i < 4; i++){

        if(check(sx, sy)){

          update(sx, sy);

        }

        rotate();

      }

    }

  }



  if(ansX == INT_MAX){

    cout << "NA\n";

  }

  else{

    cout << ansX + 1 << " " << ansY + 1 << endl;

  }

}



void show(){

  for(int i = 0; i < m; i++){

    for(int j =0; j < m; j++){

      printf("%3d", s[i][j]);

    }

    cout<<endl;

  }

  cout<<"--\n";

}



int main(){

  while(cin >> n >> m, n || m){

    ansX = INT_MAX;

    ansY = INT_MAX;



    for(int i = 0; i < n; i++){

      for(int j = 0; j < n; j++){

        cin >> t[i][j];

      }

    }



    for(int i = 0; i < m; i++){

      for(int j = 0; j < m; j++){

        cin >> s[i][j];

      }

    }



    solve();

  }

}