import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int n; static class Point{ int x; int y; Point(int x, int y){ this.x = x; this.y = y; } Point move(int dx, int dy){ if (x+dx>=0 && x+dx=0 && y+dy nextMoves = new LinkedList<>(); nextMoves.add(new Point(0,0)); while(!nextMoves.isEmpty()){ Queue moves = nextMoves; nextMoves = new LinkedList<>(); while(!moves.isEmpty()){ Point position = moves.remove(); if(position.x == n-1 && position.y == n-1) return numMoves; for (int i=0; i<8; i++){ Point nextPosition = position.move(dx[i], dy[i]); if (nextPosition!=null && !visited[nextPosition.x][nextPosition.y]) { nextMoves.add(nextPosition); visited[nextPosition.x][nextPosition.y] = true; } } } numMoves++; } return -1; } public static void main(String[] args) { Scanner in = new Scanner(System.in); n = in.nextInt(); // your code goes here for (int i=1; i