#include using namespace std; bool vis[205][205]; int mov[205][205]; int dx[6] = {-2, -2, 0, 2, 2, 0}; int dy[6] = {-1, 1, 2, 1, -1, -2}; string M[6] = {"UL", "UR", "R", "LR", "LL", "L"}; bool in_bounds(int x, int y, int n) { return x >= 0 && y >= 0 && x < n && y < n; } void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { queue > q; memset(vis, 0, sizeof(vis)); q.push(make_pair(i_start, j_start)); vis[i_start][j_start] = true; while (!q.empty()) { pair cur = q.front(); q.pop(); if (cur.first == i_end && cur.second == j_end) break; for (int i = 0; i < 6; i++) { int x1 = cur.first + dx[i], y1 = cur.second + dy[i]; if (in_bounds(x1, y1, n) && !vis[x1][y1]) { vis[x1][y1] = 1; mov[x1][y1] = i; q.push(make_pair(x1, y1)); } } } if (!vis[i_end][j_end]) cout << "Impossible\n"; else { vector ans; while (!(i_end == i_start && j_end == j_start)) { ans.push_back(M[mov[i_end][j_end]]); int x = i_end - dx[mov[i_end][j_end]]; int y = j_end - dy[mov[i_end][j_end]]; i_end = x; j_end = y; } cout << ans.size() << "\n"; for (int i = (int)ans.size() - 1; i >= 0; i--) cout << ans[i] << " "; cout << "\n"; } } int main() { int n; cin >> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }