#include #include #include #include int main() { int n, k, t; std::cin >> n >> k >> t; std::vector a(n); for (int i = 0; i < n; ++i) { char c; std::cin >> c; a[i] = (c == 'B'); } std::vector b(n); for (int &e : b) std::cin >> e; const int q = t / (2 * k), r = t % (2 * k); std::vector c(n); for (int i = 0; i < n; ++i) { c[i] = b[i]; int rt = r; bool state = a[i]; while (rt) { int p = state ? k - c[i] : c[i]; int d = std::min(rt, p); if (state) { c[i] += d; } else { c[i] -= d; } rt -= d; state = not state; } } std::sort(c.begin(), c.end()); std::vector p(n); std::iota(p.begin(), p.end(), 0); std::sort(p.begin(), p.end(), [&](int i, int j) { return b[i] < b[j]; }); std::vector ans(n); for (int i = 0; i < n; ++i) { ans[p[i]] = c[i]; } for (int i = 0; i < n; ++i) { std::cout << ans[i]; if (i + 1 != n) std::cout << ' '; } std::cout << '\n'; }