#include<iostream>
using namespace std;

#define INF 1<<30
enum{Y, X};

int main() {
    int scene[100][100], picture[4][50][50], first[4][2], ans[2];
    int n, m;
    while(cin>>n>>m, n|m) {
        for(int i=0; i<n; i++) for(int j=0; j<n; j++) cin>>scene[i][j];
        for(int i=0; i<m; i++) for(int j=0; j<m; j++) cin>>picture[0][i][j];
        for(int r=1; r<4; r++) for(int i=0; i<m; i++) for(int j=0; j<m; j++) picture[r][i][j] = picture[r-1][m-j-1][i];
        for(int r=0; r<4; r++) {
            bool found = false;
            for(int i=0; !found && i<m; i++) for(int j=0; !found && j<m; j++) {
                if(picture[r][i][j] == -1) continue;
                first[r][Y] = i;
                first[r][X] = j;
                found = true;
            }
        }
        ans[Y] = ans[X] = INF;
        for(int i=0; i<n; i++) for(int j=0; j<n; j++) {
            for(int r=0; r<4; r++) {
                bool ok = true;
                for(int y=0; ok && y<m; y++) for(int x=0; ok && x<m; x++) {
                    if(picture[r][y][x] == -1) continue;
                    if(scene[i+y][j+x] == picture[r][y][x]) continue;
                    ok = false;
                }
                if(ok) {
                    int y = i + first[r][Y] + 1, x = j + first[r][X] + 1;
                    if((y < ans[Y]) || (y == ans[Y] && x < ans[X])) {
                        ans[Y] = y;
                        ans[X] = x;
                    }
                }
            }
        }
        if(ans[Y]==INF) cout<<"NA"<<endl;
        else cout<<ans[X]<<" "<<ans[Y]<<endl;
    }
}