private static void solveEven(int n, int m, boolean switched) {
        System.out.println(0);
        for (int i = 1; i <= m; i++) {
            print(1, i, switched);
        }
        for (int j = 2; j <= n-1; j++) {
            boolean evenRow = (j % 2 == 0);
            int start = (evenRow ? m : 2);
            int end   = (evenRow ? 1 : m+1);
            int step  = (evenRow ? -1: 1);
            for (int i = start; i != end; i += step) {
                print(j, i, switched);
            }
        }
        for (int i = m; i >= 1; i--) {
            print(n, i, switched);
        }
        for (int j = n-1; j >= 1; j--) {
            print(j, 1, switched);
        }
    }