// time-limit: 2000
// problem-url: https://codeforces.com/problemset/problem/223/B
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2,fma")
// #pragma GCC optimize ("-ffloat-store")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> // order_of_key() ; *( find_by_order() ) -> kth element in set;
// using namespace __gnu_pbds;  // order_of_key(k) -> Number of elements strictly smaller than k
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 ran(seed); // ran() generates a random number

#define ld long double
// #define ll long long int
#define ll int
#define endl '\n'
#define vll vector<ll>
#define vvl vector<vll>
#define pll pair<ll,ll>
#define ppl pair<pll,ll>
#define vpll vector<pll>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
#define fo(i,b) for(i=0;i<b;++i)
#define repa(i,a,b) for(i=a;i<b;++i)
#define repb(i,a,b) for(i=a;i>=b;--i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define s(v) (ll)((v).size())
#define inf 2000000000000000010 
#define mod  1000000007
#define mod1 998244353

#define mul(a,b,m) (((a%m) * 1LL * (b%m))%m)
#define add(a,b,m) (((a)+(b)>=m) ? ((a)+(b)-(m)) : ((a)+(b)))
#define sub(a,b,m) (((a)-(b) <0) ? ((a)-(b)+(m)) : ((a)-(b)))

                            /*DEBUG*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef NPRAKHAR
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#define Time cerr << "Time : " << 1000 * ((double)clock()-start) / (double)CLOCKS_PER_SEC << "ms\n"
#else
#define debug(x...) 
#define Time 
#endif
                        /*END*/
clock_t start = clock();
ll gcd(ll a, ll b) {return (a==0) ? b : gcd(b%a,a);}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll powm(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=mul(p,a,mod_);} n>>=1; a=mul(a,a,mod_);} return p%mod_;} 
ll powi(ll a, ll mod_) {return powm(a,mod_-2,mod_);}
                          /*Code Begins*/
void pre();





void test_case(){
    ll mn , mx;
    ll i, j, k, l, r;
    ll n, m, x, y, z;
    ll sum=0, cnt=0;
    
    cin >> n >> m;
    vpll pos(n);
    vll dir(n);
    fo(i,n) cin >> pos[i].first, pos[i].second=i;
    fo(i,n){
        char c;
        cin >> c;
        if(c== 'L') dir[i]=-1;
        else dir[i]=1;
    }
    vll ans(n,-1);
    set<pll> lo, le, ro, re;
    fo(i,n){
        if(dir[i]==1){
            if(pos[i].first%2) ro.insert(pos[i]);
            else re.insert(pos[i]);
        }else{
            if(pos[i].first%2) lo.insert(pos[i]);
            else le.insert(pos[i]);
        }
    }
    set<pll> remo, reme;
    for(auto it = ro.rbegin(); it != ro.rend();++it){
        if(lo.lower_bound(*it) != lo.end()){
            ans[lo.lower_bound(*it)->second] = ans[it->second] = (lo.lower_bound(*it)->first - it->first)/2;
            // ans[lo.lower_bound(*it)->second] = lo.lower_bound(*it)->first - it->first;
            lo.erase(lo.lower_bound(*it));
        }else{
            remo.insert(*it);
        }
    }
    ro = remo;
    remo.clear();
    for(auto it = re.rbegin(); it != re.rend();++it){
        if(le.lower_bound(*it) != le.end()){
            ans[le.lower_bound(*it)->second] = ans[it->second] = (le.lower_bound(*it)->first - it->first)/2;
            // ans[le.lower_bound(*it)->second] = le.lower_bound(*it)->first - it->first;
            le.erase(le.lower_bound(*it));
        }else{
            reme.insert(*it);
        }
    }
    re = reme;
    reme.clear();
    while(ro.size() > 1u){
        auto last = ro.rbegin();
        auto prev = ++ro.rbegin();
        ans[prev->second] = ans[last->second] = m - (prev->first + last->first)/2;
        ro.erase(--ro.end());
        ro.erase(--ro.end());
    }
    while(re.size() > 1u){
        auto last = re.rbegin();
        auto prev = ++re.rbegin();
        ans[prev->second] = ans[last->second] = m - (prev->first + last->first)/2;
        re.erase(--re.end());
        re.erase(--re.end());
    }
    while(lo.size() > 1u){
        auto st = lo.begin();
        auto nex = ++lo.begin();
        ans[st->second] = ans[nex->second] = (st->first + nex->first)/2;
        lo.erase(lo.begin());
        lo.erase(lo.begin());
    }
    while(le.size() > 1u){
        auto st = le.begin();
        auto nex = ++le.begin();
        ans[st->second] = ans[nex->second] = (st->first + nex->first)/2;
        le.erase(le.begin());
        le.erase(le.begin());
    }
    
    if(ro.size() and lo.size() ){
        ans[ro.begin()->second] = ans[lo.begin()->second] = (2*m- ro.begin()->first + lo.begin()->first)/2;
    }
    if(re.size() and le.size()){
        ans[re.begin()->second] = ans[le.begin()->second] = (2*m- re.begin()->first + le.begin()->first)/2;
    }
    
    fo(i,n) cout << ans[i] << ' ';
}




int main(){
    _cin
    // cout << setprecision(20);
    int TC=1, tc=0;
    cin >> TC;
    pre();
    while(tc++ < TC){ 
        // cout << "Case #" << tc << ": ";
        test_case();
        cout << '\n';
    }    
    Time;
    return 0;
}

void pre(){

    return;
}