#include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main() { FAST_IO int n; cin >> n; i64 k, t; cin >> k >> t; vector a(n, string()); vector b(n, 0LL); vector c(n, pair()); for (auto i : views::iota(0, n)) { cin >> a[i]; } for (auto i : views::iota(0, n)) { cin >> b[i]; c[i] = pair(i, b[i]); } ranges::sort(c, {}, [](pair a) { return a.second; }); for (auto i : views::iota(0, n)) { if (a[i] == "A") { b[i] -= t; b[i] %= 2 * k; if (b[i] < 0) b[i] += 2 * k; } else { b[i] += t; b[i] %= 2 * k; } if (b[i] >= k) { b[i] = k - (b[i] - k); } } ranges::sort(b); for (auto i : views::iota(0, n)) { c[i].second = b[i]; } ranges::sort(c, {}, [](auto a) { return a.first; }); for (auto v : c) { cout << v.second << " "; } cout << endl; }