#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	bool flag=1;
	int x=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
			flag=0;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return (flag?x:~(x-1));
}
int t,n,m,ans[300001];
stack<int> q;
struct node{
	int x,y,idx;
	bool operator<(const node &oth)const
	{
		return x<oth.x; 
	}
}a[300001],odd[300001],even[300001];
int calc(int x,int y) 
{
	int res=0;
	if(a[x].x<a[y].x) 
	{
		if(!a[x].y) 
		{
			res+=a[x].x;
			a[x].x=0;
		}
		if(a[y].y) 
		{
			res+=m-a[y].x;
			a[y].x=m;
		}
	}
	else 
	{
		if(a[x].y) 
		{
			res+=m-a[x].x;
			a[x].x=m; 
		}
		if(!a[y].y) 
		{
			res+=a[y].x;
			a[y].x=0;
		}
	}
	return (res+abs(a[x].x-a[y].x))/2;
}
void solve()
{
	n=read();
	m=read();
	while(!q.empty())
		q.pop();
	for(int i=1;i<=n;i++)
		ans[i]=-1;
	for(int i=1;i<=n;i++)
	{
		a[i].x=read();
		a[i].idx=i;
	}
	for(int i=1;i<=n;i++)
	{
		char c;
		cin>>c;
		if(c=='L')
			a[i].y=0;
		else
			a[i].y=1;
	}
	int cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
		if(a[i].x&1)
			odd[++cnt1]=a[i];
		else
			even[++cnt2]=a[i];
	sort(odd+1,odd+1+cnt1);
	sort(even+1,even+1+cnt2);
	q.push(1);
	for(int i=2;i<=cnt2;i++)
	{
		if(!even[i].y&&!q.empty()) 
		{
			int x=q.top();
			q.pop();
			ans[even[i].idx]=ans[even[x].idx]=calc(even[i].idx,even[x].idx);
		}
		else 
			q.push(i);
	}
	while(!q.empty()) 
	{
		int x=q.top();
		q.pop();
		if(!q.empty()) 
		{
			int y=q.top();
			q.pop();
			ans[even[x].idx]=ans[even[y].idx]=calc(even[x].idx,even[y].idx);
		}
	}
	q.push(1);
	for(int i=2;i<=cnt1;i++)
	{
		if(!odd[i].y&&!q.empty()) 
		{
			int x=q.top();
			q.pop();
			ans[odd[i].idx]=ans[odd[x].idx]=calc(odd[i].idx,odd[x].idx);
		}
		else q.push(i);
	}
	while(!q.empty()) 
	{
		int x=q.top();
		q.pop();
		if(!q.empty()) 
		{
			int y=q.top();
			q.pop();
			ans[odd[x].idx]=ans[odd[y].idx]=calc(odd[x].idx,odd[y].idx);
		}
	}
	for(int i=1;i<=n;i++)
		cout<<ans[i]<<" ";
	cout<<endl;
}
signed main()
{
	t=read();
	while(t--)
		solve();
	return 0;
}
