#[allow(unused_imports)] use proconio::{ input, marker::{Bytes, Chars, Usize1}, }; fn main() { input! { n: usize, k: i64, mut t: i64, a: [char; n], b: [i64; n], } t %= k * 2; let mut ord = (0..n).collect::>(); ord.sort_unstable_by_key(|&i| b[i]); let mut x = (0..n) .map(|i| { let mut x = b[i]; if a[i] == 'A' { x -= t; if x < 0 { x += (0 - x) * 2; } if x > k { x -= (x - k) * 2; } } else { x += t; if x > k { x -= (x - k) * 2; } if x < 0 { x += (0 - x) * 2; } } x }) .collect::>(); x.sort_unstable(); let mut res = vec![0; n]; for i in 0..n { res[ord[i]] = x[i]; } for r in res { print!("{} ", r); } println!(); }