import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { /* enum Move { int x, int y; UL(-1,-2), UR(1,-2), R(2,0), LR(1,2), LL(-1,2), L(-2,0); Move(int x, int y) { this.x = x; this.y = y; } } */ static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. int numUL = 0, numUR = 0, numR = 0, numLR = 0, numLL = 0, numL = 0; int xDiff = i_end - i_start; int yDiff = j_end - j_start; if ((xDiff > 0 && xDiff + i_start > n) || (xDiff < 0 && xDiff + i_start < 0) || (yDiff > 0 && yDiff + j_start > n) || (yDiff < 0 && yDiff + j_start < 0)) { System.out.println("Impossible"); return; } if (xDiff > 0) { while (xDiff > 0) { // will be a combination of UR's / R's / LR's if(yDiff<=2) { numUR++; yDiff += 2; xDiff--; } else if (yDiff == 0) { numR++; xDiff-=2; } else if (yDiff >= 2) { numLR++; yDiff-=2; xDiff--; } else { break; } } } if (xDiff < 0) { while (xDiff < 0) { // will be a combination of UL's / LL's / L's if(yDiff<=2) { numUL++; yDiff += 2; xDiff++; } else if (yDiff >= 2) { numLL++; yDiff-=2; xDiff++; } else if (yDiff == 0) { numL++; xDiff+=2; } else { break; } } } if (xDiff != 0 || yDiff != 0) { System.out.println("Impossible"); return; } //numUL, numUR, numR, numLR, numLL, numL for(int i=0; i