#include<stdio.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
int flag[301000];
int pick[301000];
int ans[301000];
int x[301000];
int T,a,b,n,m;
struct name{
	int num,weizhi,ff;
};
stack<name> st;
vector<name> vt[2];
int getans(int a,int b){
	if(flag[a] == 0&&flag[b] == 0){
		return (x[a] + x[b]) / 2;
	}
	else if(flag[a] == 1&&flag[b] == 1){
		return (2*m-x[a]-x[b])/2;
	}
	else if(flag[a] == 0&&flag[b] == 1){
		if(x[a]<x[b]){
			return (m+x[a]+m-x[b])/2;
		}
		else {
			return (x[a]-x[b])/2;
		}
	}
	else if(flag[a] == 1&&flag[b] == 0){
		swap(a,b);
		if(x[a]<x[b]){
			return (m+x[a]+m-x[b])/2;
		}
		else {
			return (x[a]-x[b])/2;
		}	
	}
}
bool cmd(name a,name b){
	return a.weizhi<b.weizhi;
}
signed main(){
	string str;
	scanf("%lld",&T);
	while(T--){
		scanf("%lld%lld",&n,&m);
		vt[0].clear();
		vt[1].clear();
		for(int i = 1;i<=n;i++){
			pick[i] = 0;
			scanf("%lld",&x[i]);
		}
		for(int i = 1;i<=n;i++){
			cin>>str;
			if(str == "R"){
				flag[i] = 1;
			}
			else {
				flag[i] = 0;
			}
			if(x[i]%2==1){
				vt[1].push_back(name{i,x[i],flag[i]});
			}
			else {
				vt[0].push_back(name{i,x[i],flag[i]});
			}
		}
		sort(vt[0].begin(),vt[0].end(),cmd);
		sort(vt[1].begin(),vt[1].end(),cmd);
		for(int f = 0;f<=1;f++){
			while(!st.empty()){
				st.pop();
			}
			for(int i = 0;i<vt[f].size();i++){
				if(st.empty()){
					st.push(vt[f][i]);
					continue;
				}
				if(vt[f][i].ff == 1){
					st.push(vt[f][i]);
				}
				else {
					name top = st.top();
					pick[vt[f][i].num] = top.num;
					pick[top.num] = vt[f][i].num;
					st.pop();
				}
			}
			while(!st.empty()){
				int a = st.top().num;
				st.pop();
				if(st.empty()){
					break;
				}
				int b = st.top().num;
				st.pop();
				pick[a] = b;
				pick[b] = a;
			}
		}
		for(int i = 1;i<=n;i++){
			if(pick[i] == 0) {
				ans[i] = -1;
				continue;
			}
			if(pick[i]>i)
			ans[i] =ans[pick[i]]=getans(i,pick[i]);
		}
		for(int i = 1;i<=n;i++){
			printf("%d ",ans[i]);
		}
		printf("\n");
	}
	return 0;
}