import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; public class Main { static boolean batch = false; static boolean readFile = false; static boolean outFile = false; static int caseNum = 0; static int N, K; static int[][] d; static PrintWriter pw; public static void main(String[] args) throws Exception { if (batch) { readFile = true; } if (readFile) { if (batch) { long tl = 2000; long tw = tl - 200; long total = 0; int bidx = 0; long best = 0; int widx = 0; long worst = 1000000000000000000L; int re = 0; int tle = 0; for (int z = 0; z < 100; z++) { try { long st = System.currentTimeMillis(); long score = solve(z); long time = System.currentTimeMillis() - st; if (time > tw) { System.out.println(score + "\t" + time + "ms"); if (time > tl) { tle++; } } else { System.out.println(score); } total += score; if (score > best) { best = score; bidx = z; } if (score < worst) { worst = score; widx = z; } } catch (Exception e) { System.out.println(z + ":\t" + e.getMessage()); re++; } } System.out.println("total: " + total); System.out.println("best: " + bidx + ": " + best); System.out.println("worst: " + widx + ": " + worst); System.out.println("RE: " + re); System.out.println("TLE: " + tle); } else { long score = solve(caseNum); System.out.println(score); } } else { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); init(br); br.close(); solve(); } } static long solve(int z) throws Exception { StringBuilder sb = new StringBuilder(); sb.append(z); while (sb.length() < 4) { sb.insert(0, '0'); } File file = new File("G:\\yuki\\5025\\in\\" + sb.toString() + ".txt"); BufferedReader br = new BufferedReader(new FileReader(file)); init(br); br.close(); if (outFile) { File file2 = new File("G:\\yuki\\5025\\out\\" + sb.toString() + ".txt"); pw = new PrintWriter(file2); } long res = solve(); if (outFile) { pw.close(); } return res; } static void init(BufferedReader br) throws Exception { String[] sa = br.readLine().split(" "); N = Integer.parseInt(sa[0]); K = Integer.parseInt(sa[1]); d = new int[N][N]; for (int i = 0; i < N; i++) { char[] s = br.readLine().toCharArray(); for (int j = 0; j < N; j++) { d[i][j] = s[j] - '0'; } } } static long solve() { int n2 = N / 2; List list = new ArrayList<>(); for (int i = 0; i < N; i++) { if (d[n2][i] > 0) { list.add(toInt(n2, i)); d[n2][i] = -1; } } for (int i = 0; i < N; i++) { if (d[i][n2] > 0) { list.add(toInt(i, n2)); d[i][n2] = -1; } } if (outFile) { output(pw, list); } else if (!batch) { output(new PrintWriter(System.out), list); } long score = 0; return score; } static int toInt(int x, int y) { return x * N + y; } static void output(PrintWriter pw, List list) { pw.println(list.size()); for (int p : list) { int x = p / N; int y = p % N; pw.println(x + " " + y); } pw.flush(); } static class Ans { } }