#include<bits/stdc++.h>
#define int long long
#define ld long double

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define ff first
#define ss second


using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;


typedef pair<int, int> pii;

int power(int a, int b, int in_mod)
{
    int ans=1;
    int prod=a;
    while(b)
    {
        if(b%2)
            ans=(ans*prod)%in_mod;
        prod=(prod*prod)%in_mod;
        b/=2;
    }
    return ans;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int fact(int n,int in_mod){
    int f=1;
    for(int i=1;i<=n;i++) f=(f*i)%in_mod;
    return f;
}
int ncr(int n,int r,int in_mod){
    return (((fact(n,in_mod)*mod_inv(fact(r,in_mod),in_mod))%in_mod)*mod_inv(fact(n-r,in_mod),in_mod))%in_mod;
}

void solve()
{
    //write code here
    int n,m;
    cin>>n>>m;
    vector<pii> a(n),b(n);
    for(int i=0;i<n;i++){
        cin>>a[i].ff;
        b[i].ff=a[i].ff;
    } 
    for(int i=0;i<n;i++){
        char ch;cin>>ch;
        if(ch=='R') a[i].ss=0;
        else a[i].ss=1;
    }
    sort(all(a));
    vector<pii> c[2];
    for(int i=0;i<n;i++){
        c[a[i].ff%2].pb(a[i]);
    }


    map<int,int> mp;
    //md=1
    for(int md=0;md<2;md++){
        //l r
        if(c[md].empty()) continue;
        vector<int> lastr;
        for(int i=0;i<c[md].size();i++){
            if(c[md][i].ss==0){
                lastr.pb(c[md][i].ff);
                //cout<<(c[md][i].ff)<<endl;
            }
            else{
                if(!lastr.empty()){
                    int x=lastr[lastr.size()-1];lastr.pop_back();
                    int t=(c[md][i].ff-x)/2;
                    //cout<<t<<endl;
                    mp[x]=t;
                    mp[c[md][i].ff]=t;
                }
            }
        }


        //l l
        int lastl=-1;
        for(int i=0;i<c[md].size();i++){
            if(c[md][i].ss==1 && !mp.count(c[md][i].ff)){
                if(lastl==-1){
                    lastl=c[md][i].ff;
                }
                else{
                    int t=(c[md][i].ff+lastl)/2;
                    mp[lastl]=t;
                    mp[c[md][i].ff]=t;
                    lastl=-1;
                }
            }
        }

        //r r
        lastl=-1;
        for(int i=c[md].size()-1;i>=0;i--){
            if(c[md][i].ss==0 && !mp.count(c[md][i].ff)){
                if(lastl==-1){
                    lastl=c[md][i].ff;
                }
                else{
                    int t=(2*m-c[md][i].ff-lastl)/2;
                    mp[c[md][i].ff]=t;
                    mp[lastl]=t;
                    lastl=-1;
                }
            }
        }

        //l r
        lastl=-1;
        for(int i=0;i<c[md].size();i++){
            if(!mp.count(c[md][i].ff)){
                if(c[md][i].ss==1){
                    lastl=c[md][i].ff;
                }
                else{
                    if(lastl!=-1){
                        int t=(2*m-(c[md][i].ff-lastl))/2;
                        mp[c[md][i].ff]=t;
                        mp[lastl]=t;
                        lastl=-1;
                    }
                }
            }
        }
    }


    for(int i=0;i<n;i++){
        if(mp.count(b[i].ff)){
            cout<<mp[b[i].ff]<<" ";
        }
        else{
            cout<<-1<<" ";
        }
    }
    cout<<endl;
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(10);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((long double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}
/*
formats to remember:
1.vector<vector<int>> dp(n, vector<int>(m, 0));
--------------------------------------------------------------------------------------
1.do not use bitshift (1<<int) because it gives value in int and not in long long 
2.check that for loops of i,j,k are properly declared
3.donot delete elements from map,set while looping in it
4.in a map's vector ,ie,map<int,vector<int>> mp,when you sort each vector in a loop it may not get sorted outside the scope of the loop so take care
*/