import Foundation let n = Int(readLine()!)! var a = Array(repeating: Array(repeating: 0, count: n), count: n) class Move { var x = 0 var y = 0 var history = "" init(_ x: Int, _ y: Int) { self.x = x self.y = y } } var moves = [Move]() var nextMoves = [Move]() let input = readLine()!.components(separatedBy: " ").map({ Int($0)! }) moves.append(Move(input[0], input[1])) a[moves[0].x][moves[0].y] = 1 a[input[2]][input[3]] = 2 loop: while true { for m in moves { // UP if m.x > 1 { // UP LEFT UL if m.y > 0 { switch a[m.x-2][m.y-1] { case 1: break case 2: let next = m next.history += "UL " nextMoves = [next] break loop default: let next = Move(m.x-2, m.y-1) next.history = m.history + "UL " a[next.x][next.y] = 1 nextMoves.append(next) } } // UP RIGHT UR if m.y < n-1 { switch a[m.x-2][m.y+1] { case 1: break case 2: let next = m next.history += "UR " nextMoves = [next] break loop default: let next = Move(m.x-2, m.y+1) next.history = m.history + "UR " a[next.x][next.y] = 1 nextMoves.append(next) } } } // RIGHT R if m.y < n-2 { switch a[m.x][m.y+2] { case 1: break case 2: let next = m next.history += "R " nextMoves = [next] break loop default: let next = Move(m.x, m.y+2) next.history = m.history + "R " a[next.x][next.y] = 1 nextMoves.append(next) } } // LOW if m.x < n-2 { // LOW RIGHT DR if m.y < n-1 { switch a[m.x+2][m.y+1] { case 1: break case 2: let next = m next.history += "LR " nextMoves = [next] break loop default: let next = Move(m.x+2, m.y+1) next.history = m.history + "LR " a[next.x][next.y] = 1 nextMoves.append(next) } } // LOW LEFT DL if m.y > 0 { switch a[m.x+2][m.y-1] { case 1: break case 2: let next = m next.history += "LL " nextMoves = [next] break loop default: let next = Move(m.x+2, m.y-1) next.history = m.history + "LL " a[next.x][next.y] = 1 nextMoves.append(next) } } } // LEFT L if m.y > 1 { switch a[m.x][m.y-2] { case 1: break case 2: let next = m next.history += "L " nextMoves = [next] break loop default: let next = Move(m.x, m.y-2) next.history = m.history + "L " a[next.x][next.y] = 1 nextMoves.append(next) } } } if nextMoves.count > 0 { moves = nextMoves nextMoves = [] } else { break loop } } if nextMoves.count == 1 { print(nextMoves[0].history.components(separatedBy: " ").count-1) print(nextMoves[0].history) } else { print("Impossible") }