#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;
void solve() {
    cin >> n >> m;
    vector<pair<int, int>>a(n);
    for (int i = 0; i < n; ++i)cin >> a[i].first;
    for (int i = 0; i < n; ++i) {
        char c; cin >> c;
        a[i].second = (c == 'R' ? 1 : 0);
    }
    vector<tuple<int, int, int>>v[2];
    for (int i = 0; i < n; ++i) {
        int val = (a[i].first & 1);
        v[val].emplace_back(a[i].first, a[i].second, i);
    }
    vector<int>ans(n, -1);
    auto calc = [&](vector<tuple<int, int, int>>&v)->void {
        sort(v.begin(), v.end());
        stack<pair<int, int>>st;
        for (auto&[x, d, ind] : v) {
            if (d == 0) {
                if (st.empty())st.push(make_pair(-x, ind));
                else {
                    ans[st.top().second] = ans[ind] = (x - st.top().first) / 2;
                    st.pop();
                }
            } else st.push(make_pair(x, ind));
        }
        while (st.size() > 1) {
            pair<int, int> p = st.top();
            st.pop();
            p.first = m + (m - p.first);
            ans[p.second] = ans[st.top().second] = (p.first - st.top().first) / 2;
            st.pop();
        }
    };
    calc(v[0]), calc(v[1]);
    for (int &x : ans)cout << x << " ";
    cout << "\n";
}
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int _;
    for (cin >> _; _--;)solve();
    return 0;
}