for tc in range(int(input())):
    n = int(input())
    ans = []
    cnt = 0
    for x in range(n):
        ans.append(list(input()))

    if ans[0][1] == '0' and ans[1][0] == '0':
        if ans[n - 1][n - 2] == '0':
            cnt += 1
        if ans[n - 2][n - 1] == '0':
            cnt += 1
        if cnt == 1:
            print(cnt)
            print(n - 1, n)
        elif cnt == 2:
            print(cnt)
            print(n, n - 1)
            print(n - 1, n)
        elif cnt == 0:
            print('')
    elif ans[0][1] == '1' and ans[1][0] == '1':
        if ans[n - 1][n - 2] == '1':
            cnt += 1
        if ans[n - 2][n - 1] == '1':
            cnt += 1
        if cnt == 1:
            print(cnt)
            print(n, n - 1)
        elif cnt == 2:
            print(cnt)
            print(n, n - 1)
            print(n - 1, n)
        elif cnt == 0:
            print('')
    else:
        if ans[n - 2][n - 1] == '1':
            pass
    #print(ans)