#include<bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
const int N=3e5+9;

struct node
{
    int x;
    int i;
    int d;
};

bool comp(node x, node y)
{
    if(x.x < y.x) return true;
    return false;
}

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<node>odd,even;
    int ans[n+1];
    int a[n+1],d[n+1];
    for(int i = 1; i <= n; i++) cin >> a[i],ans[i] = -1;
    for(int i = 1; i <= n; i++)
    {
        char c; 
        cin >> c; 
        if(c == 'R') d[i] = 1; 
        else d[i] = 0;
    }
    for(int i = 1; i <= n; i++)
    {
        if(a[i] & 1) odd.pb({a[i],i,d[i]});
        else even.pb({a[i],i,d[i]});
    }
    sort(all(odd),comp);
    sort(all(even),comp);
    vector<pair<int,int>>left,right;
    for(auto c: odd)
    {
        if(c.d) right.pb({c.x,c.i});
        else
        {
            if(right.empty()) right.push_back({-c.x,c.i});
            else
            {
                int time = abs(c.x - right.back().ff) / 2;
                ans[c.i] = time, ans[right.back().ss] = time;
                right.pop_back(); 
            }
        }
    }
    
    // for(int i = 0; i + 1 < left.size(); i+=2)
    // {
    //     int time = left[i].ff + (left[i+1].ff-left[i].ff) / 2;
    //     ans[left[i].ss] = ans[left[i+1].ss] = time;
    // }
    reverse(all(right));
    for(int i = 0; i + 1 < right.size(); i+=2)
    {
       int time = m - right[i].ff + m - right[i+1].ff;
       time /= 2;
       ans[right[i].ss] = ans[right[i+1].ss] = time;
    }

    left.clear(), right.clear();

    // for even
    
    for(auto c: even)
    {
        if(c.d) right.pb({c.x,c.i});
        else
        {
            if(right.empty()) right.push_back({-c.x,c.i});
            else
            {
                int time = abs(c.x - right.back().ff)/2;
                ans[c.i] = time, ans[right.back().ss] = time;
                right.pop_back(); 
            }
        }
    }
    // for(int i = 0; i + 1 < left.size(); i+=2)
    // {
    //     int time = left[i].ff + (left[i+1].ff-left[i].ff) / 2;
    //     ans[left[i].ss] = ans[left[i+1].ss] = time;
    // }
    reverse(all(right));
  for(int i = 0; i + 1 < right.size(); i+=2)
    {
       int time = m - right[i].ff + m - right[i+1].ff;
       time /= 2;
       ans[right[i].ss] = ans[right[i+1].ss] = time;
    }
    for(int i = 1; i <= n; i++) cout << ans[i] << " "; cout << endl;
}

int main()
{
    IOS;
    int t = 1;
    cin >> t;
    while(t--) solve();

    return 0;
}