#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int MAX_N = 1000100; vector A(MAX_N); vector B(MAX_N); struct Command { int i; char direct; Command(int i = -1, char direct = '-') { this->i = i; this->direct = direct; } string to_s() { return to_string(i + 1) + " " + direct; } }; void dfs(int i, vector &positions, vector &commands) { while (A[i] != B[i]) { int a = A[i]; if (A[i] < B[i]) { if (positions[a + 1]) { dfs(i + 1, positions, commands); } else { commands.push_back(Command(i, 'R')); positions[a] = false; positions[a + 1] = true; A[i] += 1; } } else { if (positions[a - 1]) { dfs(i + 1, positions, commands); } else { commands.push_back(Command(i, 'L')); positions[a] = false; positions[a - 1] = true; A[i] -= 1; } } } } int main() { int N; cin >> N; vector positions(MAX_N, false); for (int i = 0; i < N; ++i) { cin >> A[i]; positions[A[i]] = true; } for (int i = 0; i < N; ++i) { cin >> B[i]; } vector commands; for (int i = 0; i < N; ++i) { dfs(i, positions, commands); } cout << commands.size() << endl; for (Command &cmd : commands) { cout << cmd.to_s() << endl; } return 0; }