Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.

Roger Waters has a square grid of size $n\times n$ and he wants to traverse his grid from the upper left ($1,1$) corner to the lower right corner ($n,n$). Waters can move from a square to any other square adjacent by a side, as long as he is still in the grid. Also except for the cells ($1,1$) and ($n,n$) every cell has a value $0$ or $1$ in it.

Before starting his traversal he will pick either a $0$ or a $1$ and will be able to only go to cells values in which are equal to the digit he chose. The starting and finishing cells ($1,1$) and ($n,n$) are exempt from this rule, he may go through them regardless of picked digit. Because of this the cell ($1,1$) takes value the letter 'S' and the cell ($n,n$) takes value the letter 'F'.

For example, in the first example test case, he can go from ($1, 1$) to ($n, n$) by using the zeroes on this path: ($1, 1$), ($2, 1$), ($2, 2$), ($2, 3$), ($3, 3$), ($3, 4$), ($4, 4$)

The rest of the band (Pink Floyd) wants Waters to not be able to do his traversal, so while he is not looking they will invert at most two cells in the grid (from $0$ to $1$ or vice versa). They are afraid they will not be quick enough and asked for your help in choosing the cells.  Note that you cannot invert cells $(1, 1)$ and $(n, n)$.

We can show that there always exists a solution for the given constraints.

Also note that Waters will pick his digit of the traversal after the band has changed his grid, so he must not be able to reach ($n,n$) no matter what digit he picks.


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 50$). Description of the test cases follows.

The first line of each test case contains one integers $n$ ($3 \le n \le 200$).

The following $n$ lines of each test case contain the binary grid, square ($1, 1$) being colored in 'S' and square ($n, n$) being colored in 'F'.

The sum of values of $n$ doesn't exceed $200$.


-----Output-----

For each test case output on the first line an integer $c$ ($0 \le c \le 2$)  — the number of inverted cells.

In $i$-th of the following $c$ lines, print the coordinates of the $i$-th cell you inverted. You may not invert the same cell twice.  Note that you cannot invert cells $(1, 1)$ and $(n, n)$.


-----Example-----
Input
3
4
S010
0001
1000
111F
3
S10
101
01F
5
S0101
00000
01111
11111
0001F

Output
1
3 4
2
1 2
2 1
0



-----Note-----

For the first test case, after inverting the cell, we get the following grid:



S010

0001

1001

111F

Difficulty: interview

Starter code:

Solutions:
for _ in range(int(input())):
    n = int(input())
    arr = [list(input()) for _ in range(n)]
    res = []
    if arr[n-2][n-1] == arr[n-1][n-2]:
        if arr[0][1] == arr[n-2][n-1]:
            res.append((1, 2))
        if arr[1][0] == arr[n-2][n-1]:
            res.append((2, 1))
    elif arr[0][1] == arr[1][0]:
        if arr[n-2][n-1] == arr[0][1]:
            res.append((n-1, n))
        if arr[n-1][n-2] == arr[0][1]:
            res.append((n, n-1))
    else:
        if arr[0][1] == "1":
            res.append((1, 2))
        if arr[1][0] == "1":
            res.append((2, 1))
        if arr[n-2][n-1] == "0":
            res.append((n-1, n))
        if arr[n-1][n-2] == "0":
            res.append((n, n-1))
    print(len(res))
    for e in res:
        print(*e)


import sys
input = sys.stdin.readline

def main():
    n = int(input())
    maze = [input().strip() for _ in range(n)]
    ans = []
    if maze[0][1] == "0":
        ans.append((1, 2))
    if maze[1][0] == "0":
        ans.append((2, 1))
    if maze[n - 1][n - 2] == "1":
        ans.append((n, n - 1))
    if maze[n - 2][n - 1] == "1":
        ans.append((n - 1, n))
    if len(ans) <= 2:
        print(len(ans))
        for row in ans:
            print(*row)
        return
    ans = []
    if maze[0][1] == "1":
        ans.append((1, 2))
    if maze[1][0] == "1":
        ans.append((2, 1))
    if maze[n - 1][n - 2] == "0":
        ans.append((n, n - 1))
    if maze[n - 2][n - 1] == "0":
        ans.append((n - 1, n))
    if len(ans) <= 2:
        print(len(ans))
        for row in ans:
            print(*row)
    
for _ in range(int(input())):
    main()

l = [(1, 0), (0, 1), (-1, -2), (-2, -1)]
t = int(input())
for _ in range(t):
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = 0
    for x, y in l:
        if (s[x][y] == '1') ^ (x >= 0):
            cnt += 1
    if cnt >= 2:
        print(4 - cnt)
        for x, y in l:
            if (s[x][y] == '1') ^ (x < 0):
                print(x % n + 1, y % n + 1)
    else:
        print(cnt)
        for x, y in l:
            if (s[x][y] == '1') ^ (x >= 0):
                print(x % n + 1, y % n + 1)


def main():
    n = int(input())
    lst = []
    for i in range(n):
        line = input()
        lst.append(line)
    top_left = lst[0][1]
    top_right = lst[1][0]
    bot_left = lst[n - 1][n - 2]
    bot_right = lst[n - 2][n - 1]
    if top_left == top_right:
        if bot_left == bot_right and bot_left == top_left:
            print(2)
        elif bot_left != bot_right:
            print(1)
        else:
            print(0)
        if bot_left == top_left:
            print(n, n - 1)
        if bot_right == top_right:
            print(n - 1, n)
    elif bot_left == bot_right:
        print(1)
        if bot_left == top_left:
            print(1, 2)
        if bot_right == top_right:
            print(2, 1)
    else:
        print(2)
        print(2, 1)
        if bot_left == top_left:
            print(n, n - 1)
        else:
            print(n - 1, n)


def __starting_point():
    t = int(input())
    for i in range(t):
        main()

__starting_point()

import sys
input = sys.stdin.readline
for _ in range(int(input())):
  N = int(input())
  a = [list(input())[: -1] for _ in range(N)]
  res = []
  if a[0][1] == a[1][0]:
    x = a[0][1]
    if a[-1][-2] == x: res.append((N, N - 1))
    if a[-2][-1] == x: res.append((N - 1, N))
  else:
    if a[-1][-2] == a[-2][-1]:
      x = a[-1][-2]
      if a[0][1] == x: res.append((1, 2))
      if a[1][0] == x: res.append((2, 1))
    else:
      x = a[0][1]
      res.append((2, 1))
      if a[-1][-2] == x: res.append((N, N - 1))
      if a[-2][-1] == x: res.append((N - 1, N))
  print(len(res))
  for r in res: print(*r)

def st(a, b):
    return str(a + 1) + ' ' + str(b + 1)


ans = []
for _ in range(int(input())):
    n = int(input())
    u = []
    for i in range(n):
        u.append(list(input()))
    a = [u[0][1], u[1][0], u[n - 1][n - 2], u[n - 2][n - 1]]
    if a[0] == a[1] and a[2] == a[3]:
        if a[1] != a[2]:
            ans.append(0)
        else:
            ans.append(2)
            ans.append(st(0, 1))
            ans.append(st(1, 0))
    elif a[0] == a[1]:
        ans.append(1)
        if a[2] == a[1]:
            ans.append(st(n - 1, n - 2))
        else:
            ans.append(st(n - 2, n - 1))
    elif a[2] == a[3]:
        ans.append(1)
        if a[0] == a[2]:
            ans.append(st(0, 1))
        else:
            ans.append(st(1, 0))
    else:
        ans.append(2)
        if a[0] == a[2]:
            ans.append(st(0, 1))
            ans.append(st(n - 2, n - 1))
        else:
            ans.append(st(0, 1))
            ans.append(st(n - 1, n - 2))
print('\n'.join(map(str, ans)))


def read_int():
    return int(input())


def read_ints():
    return list(map(int, input().split(' ')))


t = read_int()
for case_num in range(t):
    n = read_int()
    a = []
    for i in range(n):
        a.append(input())
    ans = []
    pos = [(0, 1), (1, 0), (n - 1, n - 2), (n - 2, n - 1)]
    target = '0011'
    for i, p in enumerate(pos):
        if a[p[0]][p[1]] != target[i]:
            ans.append((p[0] + 1, p[1] + 1))
    if len(ans) <= 2:
        print(len(ans))
        for r, c in ans:
            print(r, c)
    else:
        target = '1100'
        ans = []
        for i, p in enumerate(pos):
            if a[p[0]][p[1]] != target[i]:
                ans.append((p[0] + 1, p[1] + 1))
        print(len(ans))
        for r, c in ans:
            print(r, c)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]

for _ in range(val()):
    n = val()
    l = []
    for i in range(n):l.append(list(st()))


    ans = []
    if l[0][1] == l[1][0]:
        if l[-1][-2] == l[0][1]:
            ans.append([n - 1, n - 2])
        if l[-2][-1] == l[0][1]:
            ans.append([n - 2, n - 1])
    else:
        if l[-1][-2] == l[-2][-1]:
            if l[-1][-2] == l[0][1]:
                ans.append([0, 1])
            else:
                ans.append([1, 0])
        else:
            if l[-1][-2] == l[0][1]:
                ans.append([0, 1])
                ans.append([n - 2, n - 1])
            else:
                ans.append([1, 0])
                ans.append([n - 2, n - 1])
    
    print(len(ans))
    for i in ans:
        print(i[0] + 1, i[1] + 1)


T = int(input())

for t in range(T):
    N = int(input())
    M = []
    for i in range(N):
        M.append(input())

    inverts = []
    if M[0][1] == '0' and M[1][0] == '0':
        if M[N-2][N-1] == '0':
            inverts.append((N-2, N-1))
        if M[N-1][N-2] == '0':
            inverts.append((N-1, N-2))
    elif M[0][1] == '1' and M[1][0] == '1':
        if M[N-2][N-1] == '1':
            inverts.append((N-2, N-1))
        if M[N-1][N-2] == '1':
            inverts.append((N-1, N-2))
    elif M[0][1] == '0' and M[1][0] == '1':
        if M[N-2][N-1] == '1' and M[N-1][N-2] == '1':
            inverts.append((1, 0))
        if M[N-2][N-1] == '0' and M[N-1][N-2] == '0':
            inverts.append((0, 1))
        if M[N-2][N-1] == '1' and M[N-1][N-2] == '0':
            inverts.append((1, 0))
            inverts.append((N-1, N-2))
        if M[N-2][N-1] == '0' and M[N-1][N-2] == '1':
            inverts.append((1, 0))
            inverts.append((N-2, N-1))
    elif M[0][1] == '1' and M[1][0] == '0':
        if M[N-2][N-1] == '0' and M[N-1][N-2] == '0':
            inverts.append((1, 0))
        if M[N-2][N-1] == '1' and M[N-1][N-2] == '1':
            inverts.append((0, 1))
        if M[N-2][N-1] == '0' and M[N-1][N-2] == '1':
            inverts.append((1, 0))
            inverts.append((N-1, N-2))
        if M[N-2][N-1] == '1' and M[N-1][N-2] == '0':
            inverts.append((1, 0))
            inverts.append((N-2, N-1))

    print(len(inverts))
    for i in inverts:
        print(i[0]+1, i[1]+1)


t = int(input())

for _ in range(t):
    n = int(input())
    arr = [input() for i in range(n)]

    a = arr[0][1]
    b = arr[1][0]
    c = arr[n-2][n-1]
    d = arr[n-1][n-2]

    if (a == b):
        ans = []
        if c == a:
            ans.append([n-1, n])
        if d == a:
            ans.append([n, n-1])

        print(len(ans))
        for item in ans:
            print(item[0], item[1])

    elif (c == d):
        ans = []
        if c == a:
            ans.append([1, 2])
        if c == b:
            ans.append([2, 1])

        print(len(ans))
        for item in ans:
            print(item[0], item[1])

    else:
        if (a == c) and (b == d):
            print(2)
            print(1, 2)
            print(n, n-1)
        else:
            print(2)
            print(2, 1)
            print(n, n-1)
    


import sys
input = sys.stdin.readline
for f in range(int(input())):
    n=int(input())
    grid=[]
    for i in range(n):
        line=input()
        line=line[0:n]
        grid.append(line)
    if grid[0][1]==grid[1][0]:
        c=0
        cs=[]
        if grid[-1][-2]==grid[0][1]:
            c+=1
            cs.append([n,n-1])
        if grid[-2][-1]==grid[0][1]:
            c+=1
            cs.append([n-1,n])
        print(c)
        for x in cs:
            print(*x)
    else:
        if grid[-1][-2]==grid[-2][-1]:
            print(1)
            if grid[0][1]==grid[-1][-2]:
                print(1,2)
            else:
                print(2,1)
        else:
            print(2)
            print(2,1)
            if grid[-2][-1]==grid[0][1]:
                print(n-1,n)
            else:
                print(n,n-1)

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


import sys
input = lambda: sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
    n = int(input())
    s = []
    for _ in range(n):
        s.append(input())
    x0, x1, x2, x3 = int(s[0][1]), int(s[1][0]), int(s[-1][-2]), int(s[-2][-1])
    ans = []
    if x0==1:
        ans.append((1, 2))
    if x1==1:
        ans.append((2, 1))
    if x2==0:
        ans.append((n, n-1))
    if x3==0:
        ans.append((n-1, n))
    if len(ans)<=2:
        print(len(ans))
        for i in ans:
            print(*i)
        continue
    ans = []
    if x0==0:
        ans.append((1, 2))
    if x1==0:
        ans.append((2, 1))
    if x2==1:
        ans.append((n, n-1))
    if x3==1:
        ans.append((n-1, n))
    print(len(ans))
    for i in ans:
        print(*i)

t = int(input())

for _ in range(t):
    n = int(input())
    B = [input() for _ in range(n)]
    a,b = list(map(int, (B[0][1],B[1][0])))
    c,d = list(map(int, (B[-1][-2],B[-2][-1])))

    ans = []
    if abs(a-1)+abs(b-1) + abs(c-0)+abs(d-0) <= 2:
        if a == 0:
            ans.append((1, 2))
        if b == 0:
            ans.append((2, 1))
        if c == 1:
            ans.append((n, n-1))
        if d == 1:
            ans.append((n-1, n))
    else:
        if a == 1:
            ans.append((1, 2))
        if b == 1:
            ans.append((2, 1))
        if c == 0:
            ans.append((n, n-1))
        if d == 0:
            ans.append((n-1, n))
    print(len(ans))
    for p in ans:
        print(*p)


def testcase():

    n = int(input())
    grid = []
    for _ in range(n):
        grid.append(input())

    s1, s2 = grid[0][1], grid[1][0]
    f1, f2 = grid[-1][-2], grid[-2][-1]

    if s1 == s2:
        if f1 == f2:
            if s1 == f1:
                print(2)
                print(1, 2)
                print(2, 1)
                return
            else:
                print(0)
                return
        else:
            if s1 == f1:
                print(1)
                print(n, n - 1)
                return
            if s2 == f2:
                print(1)
                print(n - 1, n)
                return
    else:
        if f1 == f2:
            if s1 == f1:
                print(1)
                print(1, 2)
                return
            if s2 == f2:
                print(1)
                print(2, 1)
                return
        else:
            x = s2
            print(2)
            print(2, 1)
            if f1 == x:
                print(n - 1, n)
            else:
                print(n, n - 1)



    return

t = int(input())
for _ in range(t):
    testcase()