from collections import Counter
from collections import OrderedDict
from collections import defaultdict 
def freq_count(mylist):
    return Counter(mylist)
t=int(input())
for _ in range(t):
    n=int(input())
    #arr=[int(x) for x in input().split()]
    #a,b=map(int,input().split())
    #print(a^b)
    grid=[list(input()) for x in range(n)]
    print(2)
    print(1,2)
    print(2,1)
    