import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static class Coordinate { public final int x; public final int y; public final int dist; private ArrayList moveMap; public Coordinate(int x, int y, int distance) { this.x = x; this.y = y; this.dist = distance; moveMap=new ArrayList(); } public void setMap(ArrayList m){ this.moveMap = m; } public ArrayList getMap(){ return new ArrayList(this.moveMap); } } static boolean inBoard(int x, int y, int n){ return x>=0 && y>=0 && x q = new LinkedList(); String[] moveNames = {"UL", "UR", "R", "LR", "LL", "L"}; int[] xShift = {-1, 1, 2, 1, -1, -2}; int[] yShift = {-2, -2, 0, 2, 2, 0}; Coordinate root = new Coordinate(j_start,i_start,0); visited[i_start][j_start] = true; q.add(root); while(!q.isEmpty()){ Coordinate square = q.poll(); //System.out.println("square x,y: "+square.x+" "+square.y); if(square.x==j_end && square.y==i_end){ System.out.println(square.dist); ArrayList allMoves = square.getMap(); for(int m=0; m moves = square.getMap(); moves.add(moveNames[i]); newSquare.setMap(moves); visited[cx][cy] = true; q.add(newSquare); } } System.out.println("Impossible"); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int i_start = in.nextInt(); int j_start = in.nextInt(); int i_end = in.nextInt(); int j_end = in.nextInt(); printShortestPath(n, i_start, j_start, i_end, j_end); in.close(); } }