## subroutines

def rot(pic, m)
  pic0 = m.times.map{[nil] * m}

  for y in (0...m)
    for x in (0...m)
      pic0[m - 1 - x][y] = pic[y][x]
    end
  end

  pic0
end

def match?(x, y, m, wds, pic)
  for dy in (0...m)
    for dx in (0...m)
      p0 = pic[dy][dx]
      if p0 != -1 && wds[y + dy][x + dx] != p0
        return false
      end
    end
  end
  true
end

### main

while true
  n, m = gets.strip.split(' ').map{|s| s.to_i}
  break if n == 0 && m == 0

  wds = []
  n.times.each do
    wds << gets.strip.split(' ').map{|s| s.to_i}
  end

  pic0 = []
  m.times.each do
    pic0 << gets.strip.split(' ').map{|s| s.to_i}
  end

  pics = [pic0]
  for i in (0..2)
    pics << rot(pics[i], m)
  end

  ppos = []
  for pic in pics
    px = py = 0
    while pic[py][px] == -1
      px += 1
      if px >= m
        px = 0
        py += 1
      end
    end
    ppos << [px, py]
  end

  matched = false
  mx = my = nil
  d = n - m

  for y in (0..d)
    for x in (0..d)
      for i in (0..3)
        if match?(x, y, m, wds, pics[i])
          matched = true
          mx = x + ppos[i][0]
          my = y + ppos[i][1]
          break
        end
      end
      break if matched
    end
    break if matched
  end

  puts (matched ? "#{mx + 1} #{my + 1}" : 'NA')
end