import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { private static class Point { final int x, y; boolean visited = false; public Point(int x, int y) { super(); this.x = x; this.y = y; } @Override public String toString() { return "(" + x + ", " + y + ")"; } } private static enum Direction { UL, UR, R, LR, LL, L; } static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { Point [][] pontos = new Point[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { pontos[i][j] = new Point(i, j); } } final Point target = pontos[i_end][j_end]; Point current = pontos[i_start][j_start]; int totalDist = 0; double smallDist = calculateDistante(target, current); Point next = null; Point trial = null; double newDist; StringBuilder sbDirections = new StringBuilder(); Direction nextDirection = null; while (true) { // all directions from current next = null; for (Direction direction : Direction.values()) { trial = tryNext(direction, current, pontos, n); if (trial == null || trial.visited) { continue; } trial.visited = true; newDist = calculateDistante(trial, target); // sets as next to go if (newDist < smallDist) { smallDist = newDist; next = trial; nextDirection = direction; } } // move current current = next; sbDirections.append(nextDirection).append(" "); totalDist ++; if (current == target) { System.out.println(totalDist); System.out.println(sbDirections.toString()); return; } // no more trials if (next == null) { System.out.println("Impossible"); return; } } } // UL, UR, R, LR, LL, L private static Point tryNext(Direction direction, Point current, Point [][] board, int limit) { switch (direction) { case UL: if (current.x - 2 >= 0 && current.y - 1 >= 0) { return board[current.x - 2][current.y - 1]; } break; case LL: if (current.x + 2 < limit && current.y - 1 >= 0) { return board[current.x + 2][current.y - 1]; } break; case R: if (current.y + 2 < limit) { return board[current.x][current.y + 2]; } break; case LR: if (current.x + 2 < limit && current.y + 1 < limit) { return board[current.x + 2][current.y + 1]; } break; case UR: if (current.x - 2 >= 0 && current.y + 1 < limit) { return board[current.x - 2][current.y + 1]; } break; case L: if (current.y - 2 >= 0) { return board[current.x][current.y - 2]; } break; } return null; } private static double calculateDistante(Point a, Point b) { return Math.sqrt((b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y - a.y)); } 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(); } }