#![allow(dead_code)] #![allow(unused_imports)] #![allow(unused_mut)] #![allow(unused_macros)] #![allow(unused_variables)] #![allow(non_upper_case_globals)] #![allow(non_snake_case)] #![allow(unused_unsafe)] #![allow(unused_must_use)] use std::cmp::*; use std::collections::*; use std::io::{self, stdout, BufRead, BufWriter, Write}; macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } macro_rules! dd { ($($a:expr),* $(,)*) => { #[cfg(debug_assertions)] eprintln!(concat!($("\x1b[38;5;39m|\x1b[m \x1b[38;5;39m", stringify!($a), " =\x1b[m {:?} "),*, "\x1b[38;5;69m|\x1b[m \x1b[38;5;6m"), $(&$a),*); }; } macro_rules! w { ($output:expr, $x:expr) => { let _ = writeln!($output, "{}", $x); }; } fn main() { let out = stdout(); let mut out = BufWriter::new(out.lock()); input!(n: usize, a: [i64; n], b: [i64; n]); let mut ans: Vec<(usize, char)> = vec![]; let mut ai = a; let mut bi = b; for i in 0..n { while ai[i] > bi[i] { ans.push((i, 'L')); ai[i] -= 1; } } for i in (0..n).rev() { while ai[i] < bi[i] { ans.push((i, 'R')); ai[i] += 1; } } w!(out, ans.len()); for (k, v) in ans { writeln!(out, "{} {}", k + 1, v).ok(); } }