#include // #include using namespace std; using namespace numbers; int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); int n, k, t; cin >> n >> k >> t, t %= 2 * k; vector a(n); vector b(n); copy_n(istream_iterator(cin), n, a.begin()); copy_n(istream_iterator(cin), n, b.begin()); vector order(n); iota(order.begin(), order.end(), 0); ranges::sort(order, [&](int i, int j){ return b[i] < b[j]; }); vector res(n, -1); { vector amount(n); for(auto i = 0; i < n; ++ i){ int d = a[i] == 'A' ? -1 : 1; long long x = b[i] + t * d; if(x < 0){ x += 2 * k; } x %= 2 * k; if(x >= k){ x = 2 * k - x; } amount[i] = x; } ranges::sort(amount); for(auto i = 0; i < n; ++ i){ res[order[i]] = amount[i]; } } ranges::copy(res, ostream_iterator(cout, " ")); cout << "\n"; return 0; } /* */ //////////////////////////////////////////////////////////////////////////////////////// // // // Coded by Aeren // // // ////////////////////////////////////////////////////////////////////////////////////////