#include <iostream>
#include <vector>
using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;

void lotate_VVI( VVI& target )
{
	VVI next( target.size(), VI( target.size() ) );
	for ( int i = 0; i < target.size(); i++ )
	{
		for ( int j = 0; j < target.size(); j++ )
		{
			next[j][target.size()-i-1] = target[i][j];
		}
	}
	target = next;
}

class Point
{
public:
	int x;
	int y;
	Point(): x(-1), y(-1) {};
	Point( int _x, int _y ): x(_x), y(_y) {};
};

Point partly_match( const VVI& window, VVI& picture, int x, int y )
{
	bool found = true;
	Point p = Point( -1, -1 );
	for ( int i = 0; found && i < picture.size(); i++ )
	{
		for ( int j = 0; found && j < picture.size(); j++ )
		{
			int nx = x + j;
			int ny = y + i;
			if ( picture[i][j] == -1 ) continue;
			if ( picture[i][j] != window[ny][nx] ) found = false;
			if ( picture[i][j] == window[ny][nx] && p.x == -1 && p.y == -1 ) p = Point( nx, ny );
		}
	}
	if ( found ) return p;
	return Point( -1, -1 );
}

Point match( const VVI& window, VVI& picture )
{
	for ( int k = 0; k < 4; k++ )
	{
		for ( int i = 0; i <= window.size() - picture.size(); i++ )
		{
			for ( int j = 0; j <= window.size() - picture.size(); j++ )
			{
				Point result = partly_match( window, picture, j, i );
				if ( result.x != -1 && result.y != -1 )
					return result;
			}
		}
		lotate_VVI( picture );
	}
	return Point( -1, -1 );
}

int main( void )
{
	int n, m;
	while ( cin >> n >> m && n && m )
	{
		// ツ堕仰づ個景ツ色
		VVI window( n, VI( n ) );
		for ( int i = 0; i < n; i++ )
		{
			for ( int j = 0; j < n; j++ )
			{
				cin >> window[i][j];
			}
		}

		// ツ偲環真ツづ個静伉づェツ端
		VVI picture( m, VI( m ) );
		for ( int i = 0; i < m; i++ )
		{
			for ( int j = 0; j < m; j++ )
			{
				cin >> picture[i][j];
			}
		}

		Point result = match( window, picture );
		if ( result.x == -1 && result.y == -1 )
			cout << "NA" << endl;
		else
			cout << result.x + 1 << " " << result.y + 1 << endl;
	}
	return 0;
}