#include #include #include #include #include #include #define INF 1000000000 int grid[205][205] = {}; int par[205][205] = {}; std::queue > bfs; int m_i[6] = {-2, -2, 0, 2, 2, 0}; int m_j[6] = {-1, 1, 2, 1, -1, -2}; std::string ugh[6] = {"UL", "UR", "R", "LR", "LL", "L"}; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL); std::string ans = ""; int n, s_i, s_j, t_i, t_j; std::cin >> n >> s_i >> s_j >> t_i >> t_j; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) grid[i][j] = INF; bfs.push(std::make_pair(s_i, s_j)); grid[s_i][s_j] = 0; while (!bfs.empty()) { int i = bfs.front().first; int j = bfs.front().second; bfs.pop(); for (int t = 0; t < 6; t++) { if (i + m_i[t] >= 0 && i + m_i[t] < n && j + m_j[t] >= 0 && j + m_j[t] < n && grid[i + m_i[t]][j + m_j[t]] == INF) { grid[i + m_i[t]][j + m_j[t]] = grid[i][j] + 1; par[i + m_i[t]][j + m_j[t]] = t; bfs.push(std::make_pair(i + m_i[t], j + m_j[t])); } } } if (grid[t_i][t_j] == INF) std::cout << "Impossible\n"; else { std::cout << grid[t_i][t_j] << '\n'; int i = t_i; int j = t_j; while (grid[i][j] != 0) { std::string temp_ugh = ugh[par[i][j]]; std::reverse(temp_ugh.begin(), temp_ugh.end()); ans += temp_ugh; int to_sub_i = m_i[par[i][j]]; int to_sub_j = m_j[par[i][j]]; i -= to_sub_i; j -= to_sub_j; if (grid[i][j] != 0) ans += " "; } std::reverse(ans.begin(), ans.end()); std::cout << ans << '\n'; } }