t=int(input())
for i in range(t):
  n=int(input())
  x=[]
  for j in range(n):
    w=input()
    x.append(w)
  if(x[0][1]==x[1][0]):
    if(x[-1][-2]==x[-2][-1]):
      if(x[0][1]==x[-1][-2]):
        print(2)
        print(1,2)
        print(2,1)
      else:
        print(0)
    else:
      if(x[0][1]==x[-1][-2]):
        print(1)
        print(n,n-1)
      else:
        print(1)
        print(n-1,n)
  else:
    if(x[-1][-2]==x[-2][-1]):
      if(x[0][1]==x[-1][-2]):
        print(1)
        print(1,2)
      else:
        print(1)
        print(2,1)
    else:
      if(x[0][1]==x[-1][-2]):
        print(2)
        print(2,1)
        print(n,n-1)
      else:
        print(2)
        print(2,1)
        print(n-1,n)