// __author__ HD #include #define endl '\n' #define MAX 205 #define MOD 101 using namespace std; typedef long long ll; bool visited[MAX][MAX]; pair parent[MAX][MAX]; string movement[MAX][MAX]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string m[6] = {"UL", "UR", "R", "LR", "LL", "L"}; int dx [6] = {-2, -2, 0, 2, 2, 0}; int dy [6] = {-1, 1, 2, 1, -1, -2}; //Solve.... int n, xs, ys, xe, ye; cin >> n >> xs >> ys >> xe >> ye; queue> q; q.push(make_pair(xs, ys)); memset(visited, false, sizeof visited); visited[xs][ys] = true; parent[xs][ys] = make_pair(-1,-1); pair pos; while(!q.empty()) { pos = q.front(); if(pos.first == xe && pos.second == ye) break; q.pop(); for (int k = 0; k < 6; ++k) { if(pos.first + dx[k] >= 0 && pos.first + dx[k] < n && pos.second + dy[k] >= 0 && pos.second + dy[k] < n && !visited[pos.first + dx[k]][pos.second + dy[k]]){ q.push(make_pair(pos.first + dx[k], pos.second + dy[k])); visited[pos.first + dx[k]][pos.second + dy[k]] = true; parent[pos.first + dx[k]][pos.second + dy[k]] = pos; movement[pos.first + dx[k]][pos.second + dy[k]] = m[k]; } } } if(!visited[xe][ye]) cout << "Impossible" << endl; else{ string answer = ""; int count = 0; pos = parent[xe][ye]; while(parent[xe][ye].first != -1 && parent[xe][ye].second != -1){ answer = movement[xe][ye] + (count == 0 ? "" : " ") + answer; int aux = parent[xe][ye].first; int auy = parent[xe][ye].second; xe = aux; ye = auy; count++; } cout << count << endl; cout << answer << endl; } return 0; }