#include #include #include #include int main() { int n; long long k, t; std::cin >> n >> k >> t; std::vector a(n); for (auto &e : a) std::cin >> e; std::vector b(n); for (auto &e : b) std::cin >> e; std::vector c(n); for (int i = 0; i < n; ++i) c[i] = std::abs(((k + (a[i] == 'B' ? -b[i] : +b[i]) - t) % (2 * k) + 2 * k) % (2 * k) - k); 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] << " \n"[i == n - 1]; }