t=int(input())
while(t>0):
  n=int(input())
  grid=[]
  m=n
  while(m):
    grid.append(input())
    m-=1
  #print(grid,grid[1][0],grid[0][1],grid[n-1][n-2],grid[n-2][n-1])
  key=str(str(grid[1][0])+str(grid[0][1])+str(grid[n-1][n-2])+str(grid[n-2][n-1]))
  #print(key)
  num=int(key,2)
  #print("num",num)
  if(num==3 or num==12):
    print(0)
    t-=1
    continue
  dictt={
    0:[2,1,2,2,1],
    15:[2,1,2,2,1],
    1:[1,n,n-1],
    2:[1,n-1,n],
    3:[0],
    4:[1,1,2],
    5:[2,1,2,n-1,n],
    6:[2,1,2,n,n-1],
    7:[1,1,2],
    8:[1,1,2],
    9:[2,2,1,n-1,n],
    10:[2,2,1,n-1,n],
    11:[1,2,1],
    12:[0],
    13:[1,n-1,n],
    14:[1,n,n-1]
  }
  l=dictt.get(num)
  print(l[0])
  for i in range(l[0]):
    ind=2*i
    print(l[ind+1],l[ind+2])
  t-=1
  
  