#include <bits/stdc++.h>
#define pb(a)           push_back(a)
#define ll              long long int
#define scd(a)          scanf("%d",&a)
#define mp(a,b)         make_pair(a,b)
#define scl(a)          scanf("%I64d",&a)
#define scdd(a,b)       scanf("%d %d",&a,&b)
#define srt(a)          sort(a.begin(),a.end())
#define rsrt(a)         sort(a.rbegin(),a.rend())
#define scll(a,b)       scanf("%I64d %I64d",&a,&b)
#define vll             vector<ll>
#define pi              acos(-1.0)
#define inf             9223372036854775807
#define ff              first
#define ss              second
#define mod             1000000007

using namespace std;

void solve()
{
    ll n,i,j,t,m,res=0,rr=1;
    cin>>n>>m;
    vector<pair<ll,char>>v1,v2;
    vector<ll>vvl;
    vector<char>vvc;
    map<ll,ll>ans;
    for(i=0;i<n;i++)
    {
        cin>>t;
        vvl.pb(t);
    }
    char c;
    for(i=0;i<n;i++)
    {
        cin>>c;
        vvc.pb(c);
    }
    for(i=0;i<n;i++)
    {
        if(vvl[i]%2==0)v1.pb(mp(vvl[i],vvc[i]));
        else v2.pb(mp(vvl[i],vvc[i]));
    }
    srt(v1);
    srt(v2);
    stack<ll>st;
    queue<ll>qq;
    for(i=0;i<v1.size();i++)
    {
        if(v1[i].ss=='R')st.push(v1[i].ff);
        else
        {
            if(!st.empty())
            {
                t=st.top();
                st.pop();
                res=(v1[i].ff-t)/2;
                ans[t]=res;
                ans[v1[i].ff]=res;

            }
            else qq.push(v1[i].ff);
        }
    }
    while(st.size()>1)
    {
        ll t1,t2;
        t1=st.top();
        st.pop();
        t2=st.top();
        st.pop();
        t=(m-t1)+(m-t2);
        t/=2;
        res=t;
        ans[t1]=res;
        ans[t2]=res;
    }
    while(qq.size()>1)
    {
        ll t1,t2;
        t1=qq.front();
        qq.pop();
        t2=qq.front();
        qq.pop();
        t=(t1+t2)/2;
        res=t;
        ans[t1]=res;
        ans[t2]=res;
    }
    if(qq.size()||st.size())
    {
        if(qq.size()&&st.size())
        {
            ll t1,t2;
            t1=qq.front();
            t2=st.top();
            qq.pop();
            st.pop();
            t=t1+(m-t2);
            t+=(t2-t1)/2;
            res=t;
            ans[t1]=res;
            ans[t2]=res;
        }
    }

    //part2
    while(st.size())
    {
        ll t1=st.top();
        ans[t1]=-1;
        st.pop();
    }
    while(qq.size())
    {
        ll t1=qq.front();
        ans[t1]=-1;
        qq.pop();
    }
    v1=v2;
    for(i=0;i<v1.size();i++)
    {
        if(v1[i].ss=='R')st.push(v1[i].ff);
        else
        {
            if(!st.empty())
            {
                t=st.top();
                st.pop();
                res=(v1[i].ff-t)/2;
                ans[t]=res;
                ans[v1[i].ff]=res;

            }
            else qq.push(v1[i].ff);
        }
    }
    while(st.size()>1)
    {
        ll t1,t2;
        t1=st.top();
        st.pop();
        t2=st.top();
        st.pop();
        t=(m-t1)+(m-t2);
        t/=2;
        res=t;
        ans[t1]=res;
        ans[t2]=res;
    }
    while(qq.size()>1)
    {
        ll t1,t2;
        t1=qq.front();
        qq.pop();
        t2=qq.front();
        qq.pop();
        t=(t1+t2)/2;
        res=t;
        ans[t1]=res;
        ans[t2]=res;
    }
    if(qq.size()||st.size())
    {
        if(qq.size()&&st.size())
        {
            ll t1,t2;
            t1=qq.front();
            t2=st.top();
            qq.pop();
            st.pop();
            t=t1+(m-t2);
            t+=(t2-t1)/2;
            res=t;
            ans[t1]=res;
            ans[t2]=res;
        }
    }
    while(st.size())
    {
        ll t1=st.top();
        ans[t1]=-1;
        st.pop();
    }
    while(qq.size())
    {
        ll t1=qq.front();
        ans[t1]=-1;
        qq.pop();
    }

    for(i=0;i<n;i++)cout<<ans[vvl[i]]<<" ";
    cout<<endl;
}

int main()
{
    ll T=1;
    scl(T);
    while(T--)
    {
        solve();
    }
    return 0;
}
