import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static boolean[][] board; private static LinkedList fifo = new LinkedList(); private static final Point watchman = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); private static int n; public static void main(String[] args) { Scanner in = new Scanner(System.in); n = in.nextInt(); for(int row=1; row= 0 && board[movRow][movCol] == false){ fifo.add(new Point(movRow, movCol)); board[movRow][movCol] = true; } movRow = currentRow - rowMovement; movCol = currentCol - colMovement; if(movRow >=0 && movCol >= 0 && board[movRow][movCol] == false){ fifo.add(new Point(movRow, movCol)); board[movRow][movCol] = true; } movRow = currentRow - rowMovement; movCol = currentCol + colMovement; if(movRow >=0 && movCol < n && board[movRow][movCol] == false){ fifo.add(new Point(movRow, movCol)); board[movRow][movCol] = true; } } private static void init(int rowMovement, int colMovement){ fifo.clear(); board = new boolean[n][n]; board[0][0] = true; fifo.add(new Point(rowMovement, colMovement)); board[rowMovement][colMovement] = true; if(rowMovement != colMovement){ fifo.add(new Point(colMovement, rowMovement)); board[colMovement][rowMovement] = true; } fifo.add(watchman); } private static class Point{ int row; int col; Point(int row, int col){ this.row = row; this.col = col; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Point point = (Point) o; if (row != point.row) return false; return col == point.col; } @Override public int hashCode() { int result = row; result = 31 * result + col; return result; } } }