#include <bits/stdc++.h>

using namespace std;

struct robot_t {int x, d, i;};

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> ans(n, -1);
    vector<robot_t> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i].x;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        a[i].d = (s == "R");
        a[i].i = i;
    }
    vector<vector<robot_t>> b(2);
    for (int i = 0; i < n; ++i) b[a[i].x & 1].push_back(a[i]);
    for (auto &c : b) {
        sort(begin(c), end(c), [](robot_t x, robot_t y) {return x.x < y.x;});
        vector<robot_t> stk;
        for (auto &r : c) {
            if(r.d) {
                stk.push_back(r);
            } else {
                if(stk.empty()) {
                    r.x = -r.x;
                    r.d = !r.d;
                    stk.push_back(r);
                } else {
                    auto s = stk.back();
                    stk.pop_back();
                    int x = (r.x - s.x) / 2;
                    ans[r.i] = ans[s.i] = x;
                }
            }
        }
        while(stk.size() >= 2) {
            auto r = stk.back();
            stk.pop_back();
            auto s = stk.back();
            stk.pop_back();
            r.x = 2 * m - r.x;
            ans[r.i] = ans[s.i] = (r.x - s.x) / 2;
        }
    }
    for (auto &v : ans) cout << v << ' ';
    cout << '\n';
}

int main() {
    cin.tie(0) -> sync_with_stdio(false);

    int T; cin >> T; while(T--) {
        solve();
    }
}
