#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector vi; typedef pair pi; typedef pair pl; inline int toInt(string s){int v; istringstream sin(s);sin>>v;return v;} inline ll toll(string s){ll v; istringstream sin(s);sin>>v;return v;} template inline string toString(T x) { ostringstream sout; sout << x; return sout.str();} #define MAX (10000000 + 5) #define ff first #define ss second #define PI acos(-1.0) #define mp make_pair #define INF 2e9 #define llINF 4e18 #define EPS 1e-9 #define sz(v) static_cast((v).size()) #define pb(...) push_back(__VA_ARGS__) #define clr(x) memset(x, 0, sizeof(x)) #define rep(i, b) for (int i = 0 ; i < (b) ; ++i) #define rep1(i, b) for (int i = 1 ; i <= (b) ; ++i) int n; bool valid(int x){ return x >= 0 && x < n; } bool valid(int x , int y){ return valid(x) && valid(y); } string getMove(pair from , pair to){ if(to.first - from.first == -2 && to.second - from.second == 1) return "UR"; if(to.first - from.first == 2 && to.second - from.second == 1) return "LR"; if(to.first - from.first == 0 && to.second - from.second == 2) return "R"; if(to.first - from.first == -2 && to.second - from.second == -1) return "UL"; if(to.first - from.first == 2 && to.second - from.second == -1) return "LL"; if(to.first - from.first == 0 && to.second - from.second == -2) return "L"; return "*"; } int parentx[255][255] , parenty[255][255]; bool vis[255][255]; void print(int x , int y){ if(parentx[x][y] == -1 && parenty[x][y] == -1) { //cout << getMove(mp(parentx[x][y] , parenty[x][y]) , mp(x , y)); } else { print( parentx[x][y] , parenty[x][y] ); cout << getMove(mp(parentx[x][y] , parenty[x][y]) , mp(x , y)) << " "; } } int dr[] = {-2 , -2 , 0 , 2 , 2 , 0 }; int dc[] = {-1 , 1 , 2 , 1 , -1 , -2}; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; int x1 , y1 , x2 , y2; cin >> x1 >> y1 >> x2 >> y2; queue , int>> q; parentx[x1][y1] = -1; parenty[x1][y1] = -1; q.push(mp(mp(x1 , y1) , 0)); vis[x1][y1] = 1; bool done = 0; while(!q.empty()){ pair , int> cur = q.front(); q.pop(); pair node = cur.first; int d = cur.second; if(node.first == x2 && node.second == y2) { cout << d << endl; done = 1; print(node.first , node.second); } else { for(int i = 0 ; i < 6 ; i++){ if(valid(dr[i] + node.first , dc[i] + node.second)) { int nx = dr[i] + node.first; int ny = dc[i] + node.second; if(!vis[nx][ny]){ parentx[nx][ny] = node.first; parenty[nx][ny] = node.second; vis[nx][ny] = 1; q.push(mp(mp(nx , ny) , d + 1)); } } } } } if(!done) { cout << "Impossible"; } return 0; }