//code sourced from kinesis
#include<bits/stdc++.h>
using namespace std;

#define _REP(i,a,b) for(int i = (a) ; i >= (int)(b) ; --i )
#define REP(i,a,b) for(int i = (a) ; i <= (int)(b) ; ++i )
#define UREP(i,u) for(int i = p[(u)] ; i + 1 ; i = edge[i].next)
//iterator: for(int u:x),x is container
#define x(p) (p).first
#define y(p) (p).second
#define pii pair<int,int>
#define mp(x,y) make_pair((x), (y))
#define sign(x) (fabs(x) < eps ? 0 : ((x) > 0 ? 1 : -1))
#define ll long long
#define L7 __int128//1<<7 bit
#define ull unsigned long long
#define ld long double
const int inf = 0x3f3f3f3f;
//const ll inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;//inv2 = 499122177。奇素数的inv2 = (mod/2) + 1
const double eps = 1e-9;
#define ri1(x) scanf("%d", &(x))
#define ri2(x,y) scanf("%d%d", &(x), &(y))
#define ri3(x,y,z) scanf("%d%d%d", &(x), &(y), &(z))
#define ri4(a,b,c,d) scanf("%d%d%d%d", &(a), &(b), &(c), &(d))
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
//sort(f,f+n,[](int x,int y){return g[x] < g[y];});绑定sort
//fflush(stdout);交互题仅输出需要清空缓冲区.最后的输出也清空
//#define Debug
#ifdef Debug
#endif // Debug

const int N = 3e5 + 5;
int l[N],sta[N],top,m,n;

struct E
{
    int x,d,t;
}e[N];

void W(int o)
{
    top = 0;
    REP(i,1,n){
        if(e[l[i]].x % 2 == o){
            if(e[l[i]].d == 1 || !top) sta[++top] = l[i];
            else{
                e[l[i]].t = e[sta[top]].t = (e[l[i]].x - e[sta[top]].x * e[sta[top]].d) / 2;
                top--;
            }
        }
    }
    for(;top >= 2;top -= 2){
        e[sta[top]].t = e[sta[top-1]].t = (2 * m - e[sta[top]].x - e[sta[top-1]].x * e[sta[top-1]].d) / 2;
    }
    if(top){
        e[sta[top]].t = -1;
    }
}

void run()
{
    ri2(n,m);
    REP(i,1,n) ri1(e[i].x),l[i] = i;
    char w[3];
    REP(i,1,n) scanf("%s",w),e[i].d = (w[0] == 'R' ? 1 : -1);
    sort(l+1,l+n+1,[](int x,int y){return e[x].x < e[y].x;});
    W(0),W(1);
    REP(i,1,n) printf("%d%c",e[i].t,i==n?'\n':' ');
}

int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);//cf,atcoder,nowcoder needn't delete this
    #endif // ONLINE_JUDGE
    int T;
    ri1(T);
    while(T--){
        run();
    }
    return 0;
}
