#include <bits/stdc++.h>


using namespace std;
#define int long long


struct rob{
    int a, ind;
    char c;
};


bool cmp(rob a, rob b){
    return a.a < b.a;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    for (int z = 0; z < t; ++z) {
        int n, m;
        cin >> n >> m;
        vector<rob> z1(n);
        for (int i = 0; i < n; ++i) {
            cin >> z1[i].a;
            z1[i].ind = i;
        }
        for (int i = 0; i < n; ++i) {
            cin >> z1[i].c;
        }
        sort(z1.begin(), z1.end(), cmp);
        vector<int> a, b, dir1, dir2, ind1, ind2, ans(n, -1);
        for (int i = 0; i < n; ++i) {
            char c = z1[i].c;
            if (z1[i].a % 2) {
                a.push_back(z1[i].a), ind1.push_back(z1[i].ind);
                if (c == 'L') dir1.push_back(-1);
                else dir1.push_back(1);
            } else {
                b.push_back(z1[i].a), ind2.push_back(z1[i].ind);
                if (c == 'L') dir2.push_back(-1);
                else dir2.push_back(1);
            }
        }
        int l = a.size();
        vector<pair<int, int>> le, ri;
        for (int i = 0; i < l; ++i) {
            if (dir1[i] == 1) {
                le.push_back({a[i], ind1[i]});
            } else {
                if (!le.empty()) ans[ind1[i]] = ans[le.back().second] = (a[i] - le.back().first) / 2, le.pop_back();
                else ri.push_back({a[i], ind1[i]});
            }
        }
        swap(le, ri);
        l = le.size();
        for (int i = 0; i + 1 < l; i += 2) {
            ans[le[i].second] = ans[le[i + 1].second] = (le[i + 1].first + le[i].first) / 2;
        }
        l = ri.size();
        for (int i = l - 1; i > 0; i -= 2) {
            ans[ri[i].second] = ans[ri[i - 1].second] = (ri[i].first - ri[i - 1].first) / 2 + m - ri[i].first;
        }
        if (l % 2 && le.size() % 2){
            ans[le.back().second] = ans[ri[0].second] = m - (ri[0].first - le.back().first) / 2;
        }
        l = b.size();
        le.clear(), ri.clear();
        for (int i = 0; i < l; ++i) {
            if (dir2[i] == 1) {
                le.push_back({b[i], ind2[i]});
            } else {
                if (!le.empty()) ans[ind2[i]] = ans[le.back().second] = (b[i] - le.back().first) / 2, le.pop_back();
                else ri.push_back({b[i], ind2[i]});
            }
        }
        swap(le, ri);
        l = le.size();
        for (int i = 0; i + 1 < l; i += 2) {
            ans[le[i].second] = ans[le[i + 1].second] = (le[i + 1].first + le[i].first) / 2;
        }
        l = ri.size();
        for (int i = l - 1; i > 0; i -= 2) {
            ans[ri[i].second] = ans[ri[i - 1].second] = (ri[i].first - ri[i - 1].first) / 2 + m - ri[i].first;
        }
        if (l % 2 && le.size() % 2){
            ans[le.back().second] = ans[ri[0].second] = m - (ri[0].first - le.back().first) / 2;
        }
        for (int i = 0; i < n; ++i) {
            cout << ans[i] << " ";
        }
        cout << '\n';
    }
}
