/* .:*+=%@@@@@@=-. .:=@#@@@#@@#######%==*. .-=####@######%*-.....:%##%. .*@###########%+:--........-%@- .*@##############@+--.........-:%- .+##################@==%%%%=+*:----+. .-@####################%++%@@@@@=+**%@@* .%###################@%%@@@###@%+:--%@@%. -@###################@%%%%*::*%++:-----=@+. -#####################@%=++++++*:-------.-=: .+####################@%++*::-:::--::*:::***=: .@#####################%=++*::::-:::++*=##@@#@- ..#####################@%%=++**:::::**+%@#@%%##-.. .%####################@@%=+++*+****::*=@######@. .=######################@%%==+==++**+=@%@##@###+:... -#######################@@@%%%===++=@@@%=++===*::--... -########################@@@@@@@%==%%=++==@@:::::*:--. ..:#########################@@@@@@%%======++++::-..:-.--... %#############################@###@%%@@%==%=%*----.--.::---. #############################################*-:*:-:---*---- . #############################################*--*--:---*---:-. #############################################+--::--::-*::-::. ###########################################+:*-.---.---.:---*-.. ###########################################**:-----------------. ##########################################@::**:--::::::--:::::- ###########################################:--:*:::::::::**::*+* ###########################################=:::***::::::**:::*+* ############################@@@@@@#########@+****::::********+++ ############################@%%%%%@@@@@@@###%+***::::::::***+==+ ############################@%%%%%%%%%%%@####=+:::-::::-::*+=%%+ #############################@%%%%%%%%%%@#####=::--------:*=%@%+ %###########################@%%%%==%%%%%%@##@#=:------..-:+%@@%= ---------------------------------------------- -------------------------------------------- ---------------------------------------------- -------------------------------------------- ---------------------------------------------- o###########oo o##" ""##o o#" "## o#" "#o #" ## ## "## #" ## # ################### # # # # # # # # # # # # # #o # "#o ## "#o ## "#o o#" "#o ## "#o o#" "#ooo ooo#######oo ############### "######o o###"" "###o # ### o###o oooo ### oo####" o###**# #**# ############" ""##""""""""""########### # # oooooooo#"#** ## # # # # # ** ## # #o# #o# *****###ooo# ## ## o###o ## o##***## o########## #***#**##o o##" ""### #***##***# o#######o ### oo#### ##**####*# o##" ""#############"" ##****### ##" ## ##*##*### ## ### ##### ## ## ### # ## # ## ## # ## ## ## ### ## ###oo ### ""### ### ### */ #include //#pragma GCC optimize("O3") //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") //#pragma GCC target("avx,tune=native") using namespace std; typedef long long ll; typedef long double ld; mt19937 rnd(1337); ll AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MODR = 1e9 + 993; ll myrand(){ ll ZR = (XR * AR + YR * BR + CR) % MODR; XR = YR; YR = ZR; return ZR; } const int mod = 1e9 + 7; int bpow(int x, int y){ if (y == 0) return 1; if (y == 1) return x; int ret = bpow(x, y >> 1); ret = (ret * (ll)ret) % mod; if (y & 1) ret = (ret * (ll)x) % mod; return ret; } int bdiv(int x, int y){ return (x * (ll)bpow(y, mod - 2)) % mod; } const ll llinf = 1e18 + 100; const int maxn = 1e5 + 100, inf = 1e9 + 100, sq = 300; vector > moves = {{-2, -1}, {-2, 1}, {0, 2}, {2, 1}, {2, -1}, {0, -2}}; vector tp = {"UL", "UR", "R", "LR", "LL", "L"}; int q[200][200]; pair > p[200][200]; int n, sti, stj, fi, fj; bool good(int x, int y){ return x >= 0 && y >= 0 && x < n && y < n; } int main() { #ifdef ONPC //ifstream cin("a.in"); //ofstream cout("a.out"); freopen("a.in", "r", stdin); freopen("a.out", "w", stdout); #else //ifstream cin("a.in"); //ofstream cout("a.out"); //freopen("trap.in", "r", stdin); //freopen("trap.out", "w", stdout); #endif // ONPC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); queue > g; cin >> n >> sti >> stj >> fi >> fj; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) q[i][j] = inf; q[sti][stj] = 0; g.push(make_pair(sti, stj)); while (!g.empty()){ int x = g.front().first, y = g.front().second; g.pop(); for (int i = 0; i < moves.size(); i++){ int tx = moves[i].first + x, ty = moves[i].second + y; if (!good(tx, ty) || q[tx][ty] != inf) continue; q[tx][ty] = q[x][y] + 1; p[tx][ty] = make_pair(tp[i], make_pair(x, y)); g.push(make_pair(tx, ty)); } } if (q[fi][fj] == inf){ cout << "Impossible"; return 0; } cout << q[fi][fj] << '\n'; vector answer; int x = fi, y = fj; while (x != sti || y != stj){ answer.push_back(p[x][y].first); int tx = p[x][y].second.first, ty = p[x][y].second.second; x = tx; y = ty; } reverse(answer.begin(), answer.end()); for (auto i : answer) cout << i << ' '; }