import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Locale;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

public class Solution{
	public static void main(String[] args) {

		int t = StdIn.readInt();
		solve(t);
		
	}

	private static void solve(int T){
		for(int t = 1 ; t <= T ; t++){
			int n = StdIn.readInt();
            char[][] grid = new char[n][n];
            for(int i = 0 ; i < n ; i++)
                grid[i] = StdIn.readString().toCharArray();
            int count = 0;
            if(grid[0][1] == '0' && grid[1][0] == '0'){
                if(grid[n-2][n-1] == '1' && grid[n-1][n-2] == '1'){
                    StdOut.println(count);
                }else if(grid[n-2][n-1] == '0' && grid[n-1][n-2] == '0'){
                    count = 2;
                    StdOut.println(count);
                    StdOut.println((n-1) + " " + (n));
                    StdOut.println((n) + " " + (n-1));
                }else if(grid[n-2][n-1] == '1' && grid[n-1][n-2] == '0'){
                    count = 1;
                    StdOut.println(count);
                    StdOut.println((n) + " " + (n-1));
                }else if(grid[n-2][n-1] == '0' && grid[n-1][n-2] == '1'){
                    count = 1;
                    StdOut.println(count);
                    StdOut.println((n-1) + " " + (n));
                }
                continue;
            }

            if(grid[0][1] == '1' && grid[1][0] == '1'){
                if(grid[n-2][n-1] == '0' && grid[n-1][n-2] == '0'){
                    StdOut.println(count);
                }else if(grid[n-2][n-1] == '1' && grid[n-1][n-2] == '1'){
                    count = 2;
                    StdOut.println(count);
                    StdOut.println((n-1) + " " + (n));
                    StdOut.println((n) + " " + (n-1));
                }else if(grid[n-2][n-1] == '0' && grid[n-1][n-2] == '1'){
                    count = 1;
                    StdOut.println(count);
                    StdOut.println((n) + " " + (n-1));
                }else if(grid[n-2][n-1] == '1' && grid[n-1][n-2] == '0'){
                    count = 1;
                    StdOut.println(count);
                    StdOut.println((n-1) + " " + (n));
                }
                continue;
            }

            if(grid[0][1] == '0' && grid[1][0] == '1'){
                if(grid[n-2][n-1] == '0' && grid[n-1][n-2] == '0'){
                    count = 1;
                    StdOut.println(count);
                    StdOut.println("1 2");
                }else if(grid[n-2][n-1] == '1' && grid[n-1][n-2] == '1'){
                    count = 1;
                    StdOut.println(count);
                    StdOut.println("2 1");
                }else if(grid[n-2][n-1] == '0' && grid[n-1][n-2] == '1'){
                    count = 2;
                    StdOut.println(count);
                    StdOut.println("1 2");
                    StdOut.println((n) + " " + (n-1));
                }else if(grid[n-2][n-1] == '1' && grid[n-1][n-2] == '0'){
                    count = 2;
                    StdOut.println(count);
                    StdOut.println("2 1");
                    StdOut.println((n) + " " + (n-1));
                }
                continue;
            }

            if(grid[0][1] == '1' && grid[1][0] == '0'){
                if(grid[n-2][n-1] == '0' && grid[n-1][n-2] == '0'){
                    count = 1;
                    StdOut.println(count);
                    StdOut.println("2 1");
                }else if(grid[n-2][n-1] == '1' && grid[n-1][n-2] == '1'){
                    count = 1;
                    StdOut.println(count);
                    StdOut.println("1 2");
                }else if(grid[n-2][n-1] == '0' && grid[n-1][n-2] == '1'){
                    count = 2;
                    StdOut.println(count);
                    StdOut.println("2 1");
                    StdOut.println((n) + " " + (n-1));
                }else if(grid[n-2][n-1] == '1' && grid[n-1][n-2] == '0'){
                    count = 2;
                    StdOut.println(count);
                    StdOut.println("1 2");
                    StdOut.println((n) + " " + (n-1));
                }
                continue;
            }

		}
	}
}

final class StdIn {

    private static final String CHARSET_NAME = "UTF-8";

    private static final Locale LOCALE = Locale.US;

    private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\p{javaWhitespace}+");

    private static final Pattern EMPTY_PATTERN = Pattern.compile("");

    private static final Pattern EVERYTHING_PATTERN = Pattern.compile("\\A");

    private static Scanner scanner;
 
    private StdIn() { }

    public static boolean isEmpty() {
        return !scanner.hasNext();
    }

    public static boolean hasNextLine() {
        return scanner.hasNextLine();
    }


    public static boolean hasNextChar() {
        scanner.useDelimiter(EMPTY_PATTERN);
        boolean result = scanner.hasNext();
        scanner.useDelimiter(WHITESPACE_PATTERN);
        return result;
    }



    public static String readLine() {
        String line;
        try {
            line = scanner.nextLine();
        }
        catch (NoSuchElementException e) {
            line = null;
        }
        return line;
    }


    public static char readChar() {
        try {
            scanner.useDelimiter(EMPTY_PATTERN);
            String ch = scanner.next();
            assert ch.length() == 1 : "Internal (Std)In.readChar() error!"
                + " Please contact the authors.";
            scanner.useDelimiter(WHITESPACE_PATTERN);
            return ch.charAt(0);
        }
        catch (NoSuchElementException e) {
            throw new NoSuchElementException("attempts to read a 'char' value from standard input, "
                                           + "but no more tokens are available");
        }
    }  



    public static String readAll() {
        if (!scanner.hasNextLine())
            return "";

        String result = scanner.useDelimiter(EVERYTHING_PATTERN).next();
        scanner.useDelimiter(WHITESPACE_PATTERN); 
        return result;
    }



    public static String readString() {
        try {
            return scanner.next();
        }
        catch (NoSuchElementException e) {
            throw new NoSuchElementException("attempts to read a 'String' value from standard input, "
                                           + "but no more tokens are available");
        }
    }


    public static int readInt() {
        try {
            return scanner.nextInt();
        }
        catch (InputMismatchException e) {
            String token = scanner.next();
            throw new InputMismatchException("attempts to read an 'int' value from standard input, "
                                           + "but the next token is \"" + token + "\"");
        }
        catch (NoSuchElementException e) {
            throw new NoSuchElementException("attemps to read an 'int' value from standard input, "
                                           + "but no more tokens are available");
        }

    }


    public static double readDouble() {
        try {
            return scanner.nextDouble();
        }
        catch (InputMismatchException e) {
            String token = scanner.next();
            throw new InputMismatchException("attempts to read a 'double' value from standard input, "
                                           + "but the next token is \"" + token + "\"");
        }
        catch (NoSuchElementException e) {
            throw new NoSuchElementException("attempts to read a 'double' value from standard input, "
                                           + "but no more tokens are available");
        }
    }


    public static float readFloat() {
        try {
            return scanner.nextFloat();
        }
        catch (InputMismatchException e) {
            String token = scanner.next();
            throw new InputMismatchException("attempts to read a 'float' value from standard input, "
                                           + "but the next token is \"" + token + "\"");
        }
        catch (NoSuchElementException e) {
            throw new NoSuchElementException("attempts to read a 'float' value from standard input, "
                                           + "but there no more tokens are available");
        }
    }


    public static long readLong() {
        try {
            return scanner.nextLong();
        }
        catch (InputMismatchException e) {
            String token = scanner.next();
            throw new InputMismatchException("attempts to read a 'long' value from standard input, "
                                           + "but the next token is \"" + token + "\"");
        }
        catch (NoSuchElementException e) {
            throw new NoSuchElementException("attempts to read a 'long' value from standard input, "
                                           + "but no more tokens are available");
        }
    }


    public static short readShort() {
        try {
            return scanner.nextShort();
        }
        catch (InputMismatchException e) {
            String token = scanner.next();
            throw new InputMismatchException("attempts to read a 'short' value from standard input, "
                                           + "but the next token is \"" + token + "\"");
        }
        catch (NoSuchElementException e) {
            throw new NoSuchElementException("attempts to read a 'short' value from standard input, "
                                           + "but no more tokens are available");
        }
    }


    public static byte readByte() {
        try {
            return scanner.nextByte();
        }
        catch (InputMismatchException e) {
            String token = scanner.next();
            throw new InputMismatchException("attempts to read a 'byte' value from standard input, "
                                           + "but the next token is \"" + token + "\"");
        }
        catch (NoSuchElementException e) {
            throw new NoSuchElementException("attempts to read a 'byte' value from standard input, "
                                           + "but no more tokens are available");
        }
    }


    public static boolean readBoolean() {
        try {
            String token = readString();
            if ("true".equalsIgnoreCase(token))  return true;
            if ("false".equalsIgnoreCase(token)) return false;
            if ("1".equals(token))               return true;
            if ("0".equals(token))               return false;
            throw new InputMismatchException("attempts to read a 'boolean' value from standard input, "
                                           + "but the next token is \"" + token + "\"");
        }
        catch (NoSuchElementException e) {
            throw new NoSuchElementException("attempts to read a 'boolean' value from standard input, "
                                           + "but no more tokens are available");
        }

    }


    public static String[] readAllStrings() {

        String[] tokens = WHITESPACE_PATTERN.split(readAll());
        if (tokens.length == 0 || tokens[0].length() > 0)
            return tokens;

        String[] decapitokens = new String[tokens.length-1];
        for (int i = 0; i < tokens.length - 1; i++)
            decapitokens[i] = tokens[i+1];
        return decapitokens;
    }


    public static String[] readAllLines() {
        ArrayList<String> lines = new ArrayList<String>();
        while (hasNextLine()) {
            lines.add(readLine());
        }
        return lines.toArray(new String[lines.size()]);
    }


    public static int[] readAllInts() {
        String[] fields = readAllStrings();
        int[] vals = new int[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Integer.parseInt(fields[i]);
        return vals;
    }


    public static long[] readAllLongs() {
        String[] fields = readAllStrings();
        long[] vals = new long[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Long.parseLong(fields[i]);
        return vals;
    }


    public static double[] readAllDoubles() {
        String[] fields = readAllStrings();
        double[] vals = new double[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Double.parseDouble(fields[i]);
        return vals;
    }

    static {
        resync();
    }


    private static void resync() {
        setScanner(new Scanner(new java.io.BufferedInputStream(System.in), CHARSET_NAME));
    }
    
    private static void setScanner(Scanner scanner) {
        StdIn.scanner = scanner;
        StdIn.scanner.useLocale(LOCALE);
    }

    @Deprecated
    public static int[] readInts() {
        return readAllInts();
    }


    @Deprecated
    public static double[] readDoubles() {
        return readAllDoubles();
    }


    @Deprecated
    public static String[] readStrings() {
        return readAllStrings();
    }    

}



final class StdOut {

    private static final String CHARSET_NAME = "UTF-8";

    private static final Locale LOCALE = Locale.US;

    private static PrintWriter out;

    static {
        try {
            out = new PrintWriter(new OutputStreamWriter(System.out, CHARSET_NAME), true);
        }
        catch (UnsupportedEncodingException e) {
            System.out.println(e);
        }
    }

    private StdOut() { }

    public static void println() {
        out.println();
    }

    public static void println(Object x) {
        out.println(x);
    }

    public static void println(boolean x) {
        out.println(x);
    }

    public static void println(char x) {
        out.println(x);
    }

    public static void println(double x) {
        out.println(x);
    }

    public static void println(float x) {
        out.println(x);
    }

    public static void println(int x) {
        out.println(x);
    }

    public static void println(long x) {
        out.println(x);
    }

    public static void println(short x) {
        out.println(x);
    }

    public static void println(byte x) {
        out.println(x);
    }

    public static void print() {
        out.flush();
    }

    public static void print(Object x) {
        out.print(x);
        out.flush();
    }

    public static void print(boolean x) {
        out.print(x);
        out.flush();
    }

    public static void print(char x) {
        out.print(x);
        out.flush();
    }

    public static void print(double x) {
        out.print(x);
        out.flush();
    }

    public static void print(float x) {
        out.print(x);
        out.flush();
    }

    public static void print(int x) {
        out.print(x);
        out.flush();
    }

    public static void print(long x) {
        out.print(x);
        out.flush();
    }

    public static void print(short x) {
        out.print(x);
        out.flush();
    }

    public static void print(byte x) {
        out.print(x);
        out.flush();
    }

    public static void printf(String format, Object... args) {
        out.printf(LOCALE, format, args);
        out.flush();
    }

    public static void printf(Locale locale, String format, Object... args) {
        out.printf(locale, format, args);
        out.flush();
    }

}