#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let n = read::(); let mut a = read_vec::(); let b = read_vec::(); let mut opes = vec![vec![0]]; for i in 1..n { if (a[i] <= b[i]) != (a[i - 1] <= b[i - 1]) { opes.push(vec![]); } let last = opes.len() - 1; opes[last].push(i); } debug!(opes); let mut answers = vec![]; for ref mut block in &mut opes { if a[block[0]] <= b[block[0]] { block.reverse(); } for &i in block.iter() { for _ in 0..(a[i] - b[i]).abs() { if a[i] <= b[i] { answers.push((i, 'R')); } else { answers.push((i, 'L')); } } } } println!("{}", answers.len()); for (i, ch) in answers { println!("{} {}", i + 1, ch); } } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }