#include using namespace std; vector dir = {"UL", "UR", "R", "LR", "LL", "L"}; vector dx = {-2, -2, 0, 2, 2, 0}; vector dy = {-1, 1, 2, 1, -1, -2}; const int maxn = 205; int dist[maxn][maxn]; int from[maxn][maxn]; pair fxy[maxn][maxn]; void printShortestPath(int n, int sx, int sy, int tx, int ty) { queue> o; o.emplace(sx, sy); const int inf = 1e9; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { dist[i][j] = inf; } } dist[sx][sy] = 0; while (!o.empty()) { int x = o.front().first; int y = o.front().second; o.pop(); for (int dir = 0; dir < 6; ++dir) { int tx = x + dx[dir]; int ty = y + dy[dir]; if (tx < 0 || ty < 0 || tx >= n || ty >= n || dist[tx][ty] != inf) { continue; } from[tx][ty] = dir; fxy[tx][ty] = {x, y}; dist[tx][ty] = dist[x][y] + 1; o.emplace(tx, ty); } } if (dist[tx][ty] == inf) { cout << "Impossible\n"; return; } cout << dist[tx][ty] << '\n'; vector path; while (tx != sx || ty != sy) { int dir = from[tx][ty]; path.push_back(dir); tie(tx, ty) = fxy[tx][ty]; } reverse(path.begin(), path.end()); for (auto d : path) { cout << dir[d] << ' '; } cout << '\n'; } int main() { #ifdef LOCAL assert(freopen("b.in", "r", stdin)); #endif 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; }