use std::io::Read; fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let n: usize = it.next().unwrap().parse().unwrap(); let _m: usize = it.next().unwrap().parse().unwrap(); let mut q: std::collections::VecDeque<_> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect(); let s: Vec = it.next().unwrap().chars().collect(); for c in s { if c == 'L' { let v = q.pop_front().unwrap(); q.push_back(0); *q.front_mut().unwrap() += v; } else { let v = q.pop_back().unwrap(); q.push_front(0); *q.back_mut().unwrap() += v; } } let mut ans = String::new(); for a in q { ans.push_str(&format!("{} ", a)); } ans.pop(); println!("{}", ans); } fn main() { run(); }