#include <bits/stdc++.h>
using namespace std;
void solve()
{
    int n, m;
    cin >> n >> m;
    vector<pair<int, pair<int, int> > > bots(n);
    vector<int> ans(n, -1);
    for (int i = 0; i < n; ++i)
    {
        cin >> bots[i].first;
        bots[i].second.second = i;
    }
    for (int i = 0; i < n; ++i)
    {
        char d;
        cin >> d;
        if (d == 'L')
            bots[i].second.first = -1;
        else
            bots[i].second.first = 1;
    }
    vector<pair<int, pair<int, int> > > pos[2];
    for (int i = 0; i < n; ++i)
    {
        pos[bots[i].first & 1].push_back(bots[i]);
    }
    for (int i = 1; i >= 0; --i)
    {
        sort(pos[i].begin(), pos[i].end());
        stack<pair<int, pair<int, int> > > st;
        for (auto p: pos[i])
        {
            if (p.second.first == 1)
                st.push(p);
            else
            {
                if (st.empty())
                    st.push(p);
                else
                {
                    int idx = st.top().second.second;
                    int d = st.top().second.first;
                    int tim = abs(st.top().first * d - p.first) / 2;
                    ans[idx] = tim;
                   
                    ans[p.second.second] = tim;
                    st.pop();
                }
            }
        }
        while (st.size() > 1)
        {
            int idx1 = st.top().second.second;
            st.pop();
            int idx2 = st.top().second.second;
            st.pop();
            ans[idx2] = ans[idx1] = (2 * m - bots[idx1].first - bots[idx2].first * bots[idx2].second.first) / 2;
        }
    }
    for (int &a: ans)
        cout << a << ' ';
    cout << '\n';
}
int main(int argc, char const *argv[])
{
    int t;
    cin >> t;
    while (t --)
        solve();
    return 0;
}