#include using namespace std; #define ll long long #define mod 1000000007LL #define eps 1e-13 #define PI 3.141592653589793238L #define INF 1000000011 #define INFLL 1000000000000000011LL // #define space printf(" ") #define endl '\n' #define vi vector #define vll vector #define vc vector #define vs vector #define pii pair #define pll pair #define pil pair #define pli pair #define pcc pair #define pdd pair #define mp make_pair #define F first #define S second #define pb(x) push_back(x) #define fo(i,a,n) for(i = (a); i < (n); i++) #define sd(x) scanf("%d", &(x)) #define pd(x) printf("%d", (x)) #define pdn(x) printf("%d\n", (x)) #define slld(x) scanf("%lld", &(x)) #define plld(x) printf("%lld", (x)) #define plldn(x) printf("%lld\n", (x)) #define sllf(x) scanf("%llf", &(x)) #define pllf(x) printf("%.9llf", (x)) #define pllfn(x) printf("%.9llf\n", (x)) #define sch(x) scanf("%c", &(x)) #define pch(x) printf("%c", (x)) #define pchn(x) printf("%c\n", (x)) #define gtl(x) getline(cin, (x)) #define flsh fflush(stdout) #define sws ios_base::sync_with_stdio(false); cin.tie(0) #define gcd __gcd #define clr(x) memset(x,0,sizeof(x)) #define all(a) (a).begin(), (a).end() #define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i) #define sz(a) (int)((a).size()) #define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin);freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout) ll modx(ll Base, ll exponent) { ll ans = 1; if(Base == 1) return Base; while(exponent) { if(exponent & 1) ans = (ans * Base)%mod; Base = (Base * Base)%mod; exponent = exponent >> 1; } return ans; } ll inmodx(ll num) { return (modx(num, mod-2LL)); } bool cmp()//true for a before b { bool ans = 0; return ans; } struct ST_Node { ST_Node() { return; } void assign_value_(int val) { return; } void merge_nodes_(ST_Node& left, ST_Node& right) { return; } }; const int N = (5e2) + 9; const int M = (N<<2) + 9; const int LOGN = ((int)log2(N)) + 3; const int LOGM = ((int)log2(M)) + 3; const int BUCK = 100; queue < pii > q; int dp[N][N], par[N][N]; string s[7]; void add_node(int x, int y, int n, int val, int ind) { if(x < 0 || x >= n || y < 0 || y >= n) return; if(dp[x][y] < INF) return; dp[x][y] = val; par[x][y] = ind; q.push(mp(x,y)); return; } void shift(int &x, int &y, int val) { if(val == 1) { x -= 2; return; } if(val == 2) { x -= 1; y -= 2; return; } if(val == 3) { x += 1; y -= 2; return; } if(val == 4) { x += 2; return; } if(val == 5) { x += 1; y += 2; return; } if(val == 6) { x -= 1; y += 2; return; } } vector < string > ans; int main() { sws; // clock_t clk; // clk = clock(); //io_file; // srand (time(NULL)); //Code here int n, x1, y1, x2, y2, i, j, x, y; pii z; s[1] = "R"; s[2] = "LR"; s[3] = "LL"; s[4] = "L"; s[5] = "UL"; s[6] = "UR"; cin >> n; cin >> x1 >> y1 >> x2 >> y2; swap(x1,y1); swap(x2,y2); fo(i,0,n+1) fo(j,0,n+1) { dp[i][j] = INF; par[i][j] = -1; } dp[x1][y1] = 0; par[x1][y1] = 0; q.push(mp(x1,y1)); while(!q.empty()) { z = q.front(); q.pop(); add_node(z.F-1,z.S-2,n,dp[z.F][z.S]+1,5); add_node(z.F+1,z.S-2,n,dp[z.F][z.S]+1,6); add_node(z.F+2,z.S,n,dp[z.F][z.S]+1,1); add_node(z.F+1,z.S+2,n,dp[z.F][z.S]+1,2); add_node(z.F-1,z.S+2,n,dp[z.F][z.S]+1,3); add_node(z.F-2,z.S,n,dp[z.F][z.S]+1,4); } if(dp[x2][y2] == INF) cout << "Impossible"; else { cout << dp[x2][y2] << '\n'; x = x2; y = y2; fo(i,0,dp[x2][y2]) { ans.pb(s[par[x][y]]); shift(x,y,par[x][y]); } reverse(all(ans)); fo(i,0,sz(ans)) cout << ans[i] << " "; } // Code ends here // clk = clock() - clk; // cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n"; return 0; }