#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define PI 3.14159265359 #define all(v) v.begin(),v.end() #define sortva(v) sort(all(v)) #define sortvd(v) sort(v.rbegin(),v.rend()) #define sortaa(a,n) sort(a,a+n) #define sortad(a,n) sort(a,a+n),reverse(a,a+n) #define sfi1(v) scanf("%d",&v) #define sfi2(v1,v2) scanf("%d %d",&v1,&v2) #define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3) #define sfll1(v) scanf("%I64d",&v); #define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2) #define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3) #define sfstr(v) scanf("%s", v); #define sz(v) (int)v.size() #define ndl puts("") #define SS stringstream typedef long long ll; typedef unsigned long long ull; typedef long double ld; int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 }; int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 }; ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; } void PLAY() { //#ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); //#endif cout << fixed << setprecision(10); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } pair, string> path[205][205]; int cost[205][205]; int dxx[6] = { -2, -2, 0, 2, 2, 0 }; int dyy[6] = { -1, 1, 2, 1, -1, -2 }; string mov[6] = { "UL", "UR", "R", "LR", "LL", "L" }; int n; bool valid(int i, int j) { return i >= 0 && i < n && j >= 0 && j < n; } bool vis[205][205]; int main() { PLAY(); cin >> n; int startx, starty, endx, endy; cin >> startx >> starty >> endx >> endy; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cost[i][j] = INT_MAX; priority_queue>, vector>>, greater>>> qu; qu.push({ 0, { startx, starty } }); cost[startx][starty] = 0; bool ok = false; while (sz(qu)) { int x = qu.top().second.first; int y = qu.top().second.second; int cur_cost = qu.top().first; qu.pop(); if (vis[x][y]) continue; vis[x][y] = true; for (int i = 0; i < 6; i++) { int tox = dxx[i] + x; int toy = dyy[i] + y; if (!valid(tox, toy) || vis[tox][toy]) continue; if (cost[tox][toy] > cur_cost) { cost[tox][toy] = cur_cost + 1; path[tox][toy] = { { x, y }, mov[i] }; qu.push({ cost[tox][toy], { tox, toy } }); } } } if (cost[endx][endy] == INT_MAX) cout << "Impossible" << endl; else { cout << cost[endx][endy] << endl; vector res; while (endx != startx || endy != starty) { res.push_back(path[endx][endy].second); int tmpx = endx, tmpy = endy; endx = path[tmpx][tmpy].first.first; endy = path[tmpx][tmpy].first.second; } reverse(all(res)); for (int i = 0; i < sz(res); i++) if (res[i] == "UL") cout << res[i] << " "; for (int i = 0; i < sz(res); i++) if (res[i] == "UR") cout << res[i] << " "; for (int i = 0; i < sz(res); i++) if (res[i] == "R") cout << res[i] << " "; for (int i = 0; i < sz(res); i++) if (res[i] == "LR") cout << res[i] << " "; for (int i = 0; i < sz(res); i++) if (res[i] == "LL") cout << res[i] << " "; for (int i = 0; i < sz(res); i++) if (res[i] == "L") cout << res[i] << " "; } return 0; }