#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
 
using namespace std;


signed main() {
    int amm;
    cin >> amm;
    for (int t = 0; t < amm; t++) {
        int n, m;
        cin >> n >> m;
        vector<int> x(n);
        for (int i = 0; i < n; i++) {
            cin >> x[i];
        }
        vector <char> nap(n);
        for (int i = 0; i < n; i++) {
            cin >> nap[i];
        }
        vector <vector <pair<pair<int, char>, int>>> rob(2);
        for (int i = 0; i < n; i++) {
            rob[x[i] % 2].push_back({{x[i], nap[i]}, i});
        }
        sort(rob[0].begin(), rob[0].end());
        sort(rob[1].begin(), rob[1].end());
        vector <int> ans(n, -1);
        vector <pair<int, int>> st;
        for (auto nw : rob[0]) {
            if (nw.first.second == 'L') {
                if (st.size() == 0) {
                    st.push_back({nw.second, -nw.first.first});
                }
                else {
                    int i2 = st.back().first;
                    int x2 = st.back().second;
                    st.pop_back();
                    ans[nw.second] = abs(nw.first.first - x2) / 2;
                    ans[i2] = ans[nw.second];
                }
            }
            else {
                st.push_back({nw.second, nw.first.first});
            }
        }
        while (st.size() >= 2) {
            int i1 = st.back().first;
            int x1 = st.back().second;
            st.pop_back();
            x1 = m + (m - x1);
            int i2 = st.back().first;
            int x2 = st.back().second;
            st.pop_back();
            ans[i1] = abs(x1 - x2) / 2;
            ans[i2] = abs(x1 - x2) / 2;
        }
        st.clear();
        for (auto nw : rob[1]) {
            if (nw.first.second == 'L') {
                if (st.size() == 0) {
                    st.push_back({nw.second, -nw.first.first});
                }
                else {
                    int i2 = st.back().first;
                    int x2 = st.back().second;
                    st.pop_back();
                    ans[nw.second] = abs(nw.first.first - x2) / 2;
                    ans[i2] = ans[nw.second];
                }
            }
            else {
                st.push_back({nw.second, nw.first.first});
            }
        }
        while (st.size() >= 2) {
            int i1 = st.back().first;
            int x1 = st.back().second;
            st.pop_back();
            x1 = m + (m - x1);
            int i2 = st.back().first;
            int x2 = st.back().second;
            st.pop_back();
            ans[i1] = abs(x1 - x2) / 2;
            ans[i2] = abs(x1 - x2) / 2;
        }
        for (auto e: ans) {
            cout << e << " ";
        }
        cout << "\n";
    }
}
