using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace aizu1
{
    public class Solution
    {
        public static void Main(string[] args)
        {
            string result = "";
            while (true)
            {
                string[] s = Console.ReadLine().Split(' ');
                int n = int.Parse(s[0]), m = int.Parse(s[1]);
                if (n == 0 || m == 0||n<m) break;

                string res = findPic(n, m);

                result += res;
            }
            Console.Write(result);   
        }
        
        public static string findPic(int n,int m)
        {
            int[] res = new int[2];
            res[0] = n -m+ 1;res[1] = n-m + 1;
            int[,] w = new int[n, n];
            int[,] p1 = new int[m, m], p2 = new int[m, m], p3 = new int[m, m], p4 = new int[m, m];
            int[,] f = new int[4, 2] { { -1,-1}, { -1,-1}, { -1,-1}, { -1,-1} }; 

            for (int i1 = 0; i1 < n; i1++)
            {
                string[] wS = Console.ReadLine().Split(' ');

                for (int j1 = 0; j1 < n; j1++)
                {
                    w[i1, j1] = int.Parse(wS[j1]);
                }
            }

            for (int i2 = 0; i2 < m; i2++)
            {
                string[] pS = Console.ReadLine().Split(' ');

                for (int j2 = 0; j2 < m; j2++)
                {
                    p1[i2, j2] = int.Parse(pS[j2]);
                    if (f[0, 0] == -1 && p1[i2, j2] != -1) { f[0, 0] = i2;f[0, 1] = j2; }
                }
            }

                for (int i3 = 0; i3 < m; i3++)
                {
                    for (int j3 = 0; j3 < m; j3++)
                    {
                        p2[i3, j3] = p1[j3, m - i3 - 1];
                        if (f[1, 0] == -1 && p2[i3, j3] != -1) { f[1, 0] = i3; f[1, 1] = j3; }
                        p3[i3, j3] = p1[m - i3 - 1, m - j3 - 1];
                        if (f[2, 0] == -1 && p3[i3, j3] != -1) { f[2, 0] = i3; f[2, 1] = j3; }
                        p4[i3, j3] = p1[m - j3 - 1, i3];
                        if (f[3, 0] == -1 && p4[i3, j3] != -1) { f[3, 0] = i3; f[3, 1] = j3; }
                    }
                }

                for(int i=0;i<res[0];i++)
                {
                    for(int j=0;j<res[1];j++)
                    { 

                         bool isFind1 = true, isFind2 = true, isFind3 = true, isFind4 = true;

                        for (int k = 0; k <m;k++)
                        {
                            for(int l=0;l<m;l++)
                            {
                                isFind1 = isFind1 && (p1[k, l] == -1 || w[i + k, j + l] == p1[k, l]);
                                isFind2 = isFind2 && (p2[k, l] == -1 || w[i + k, j + l] == p2[k, l]);
                                isFind3 = isFind3 && (p3[k, l] == -1 || w[i + k, j + l] == p3[k, l]);
                                isFind4 = isFind4 && (p4[k, l] == -1 || w[i + k, j + l] == p4[k, l]);
                            }
                        }
                        if (isFind1 || isFind2 || isFind3 || isFind4)
                        {
                           if(isFind1)
                           {
                              res[0] = f[0,0]+i;
                              res[1] = f[0, 1]+j;
                           }
                           if (isFind2)
                          {
                              res[0] = f[1, 0]+i;
                              res[1] = f[1, 1]+j;
                          }
                          if (isFind3)
                          {
                              res[0] = f[2, 0]+i;
                              res[1] = f[2, 1]+j;
                          }
                          if (isFind4)
                          {
                             res[0] = f[3, 0]+i;
                             res[1] = f[3, 1]+j;
                          }
                      } 

                    }
                }

               if (res[0] != n - m + 1) return (res[1]+1)+" "+(res[0]+1)+"\n";
               return "NA\n";
        }
    }
}

Measured memory_bytes: 9456