#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ODD 1
#define EVEN 0
using namespace std;
typedef pair<ll, ll> pi;

struct Node
{
    ll x, idx;
    char dir;
};

void clear_stack(stack<Node> &a)
{
    while (!a.empty())
        a.pop();
}

void solve()
{
    ll n, m;
    cin >> n >> m;

    vector<Node> robots(n);

    for (ll i = 0; i < n; i++)
        cin >> robots[i].x;
    for (ll i = 0; i < n; i++)
    {
        cin >> robots[i].dir;
        robots[i].idx = i;
    }

    sort(robots.begin(), robots.end(), [](const Node &a, const Node &b)
         { return a.x < b.x; });

    vector<ll> ans(n, -1);
    stack<Node> match[2]; // odd
    for (ll i = 0; i < n; i++)
    {
        ll odd = robots[i].x % 2;
        if (robots[i].dir == 'R')
            match[odd].push(robots[i]);
        else if (!match[odd].empty())
        {
            Node other = match[odd].top();
            match[odd].pop();
            ans[other.idx] = ans[robots[i].idx] = abs(other.x - robots[i].x) / 2;
        }
    }

    clear_stack(match[0]), clear_stack(match[1]);

    for (ll i = 0; i < n; i++)
    {
        if (robots[i].dir == 'R' || ans[robots[i].idx] != -1)
            continue;
        ll odd = robots[i].x % 2;
        if (!match[odd].empty())
        {
            Node curr = match[odd].top();
            match[odd].pop();
            ll dist = abs((-curr.x) - robots[i].x);
            ans[curr.idx] = ans[robots[i].idx] = dist / 2;
        }
        else
        {
            match[odd].push(robots[i]);
        }
    }

    stack<Node> matchR[2];

    for (ll i = n - 1; i >= 0; i--)
    {
        if (robots[i].dir == 'L' || ans[robots[i].idx] != -1)
            continue;
        // cout << "i = " << i << '\n';
        ll odd = robots[i].x % 2;
        // cout << "odd = " << odd << '\n';
        if (!matchR[odd].empty())
        {
            Node curr = matchR[odd].top();
            // cout << "matching robot " << curr.idx << " to robot " << robots[i].idx << '\n';
            matchR[odd].pop();
            ll dist = abs((2 * m - curr.x) - robots[i].x);
            ans[curr.idx] = ans[robots[i].idx] = dist / 2;
        }
        else
        {
            matchR[odd].push(robots[i]);
        }
    }

    for (int i = 0; i < 2; i++)
    {
        if (!match[i].empty() && !matchR[i].empty())
        {
            Node l = match[i].top(), r = matchR[i].top();
            ll distL = -l.x, distR = 2 * m - r.x;
            ll dist = abs(distR - distL);
            ans[l.idx] = ans[r.idx] = dist / 2;
        }
    }

    for (auto x : ans)
        cout << x << " ";
    cout << '\n';
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    cin >> t;
    while (t--)
        solve();
    return 0;
}