#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<cstring>
#define ESP 10e-9
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x);
using namespace std;
vector<pair<pair<int,int>,int> >odd;
vector<pair<pair<int,int>,int> >eve;
int a[300005];
int ans[300005];
int main()
{
	

	int t;
	cin>>t;
	while (t--)
	{
		memset(ans,0,sizeof(ans));
		int n,m;
		cin>>n>>m;
		odd.clear();
		eve.clear();
		for (int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		for (int i=0;i<n;i++)
		{
			char c;
			cin>>c;
			int f;
			if (c=='L')
			{
				f=0;
			}
			else
			{
				f=1;
			}
			if (a[i] & 1)
			{
				odd.pb(mp(mp(a[i],f),i));
			}
			else
			{
				eve.pb(mp(mp(a[i],f),i));
			}
		}
		
		sort(odd.begin(),odd.end());
		sort(eve.begin(),eve.end());
		//////clide in begining
		for (int i=1;i<odd.size();i++)
		{
			if (odd[i].first.first==odd[i-1].first.first)
			{
				ans[odd[i].second]=0;
				ans[odd[i-1].second]=0;
				i++;
			}
		}
		//// face to face
		stack<int> st;
		for (int i=0;i<odd.size();i++)
		{
			if (ans[odd[i].second]) continue;
			if (odd[i].first.second==1)
			{
				st.push(i);
				continue;
			}
			if (st.empty())
			{
				continue;
			}
			int tp=st.top();
			st.pop();
			int tans=(odd[i].first.first-odd[tp].first.first)>>1;
			ans[odd[i].second]=tans;
			ans[odd[tp].second]=tans;
			//cout<<"**"<<endl;
		}
		//cout<<"**"<<endl;
		////face to back
		//while (!st.empty())st.pop();
		int lst=-1;
		for (int i=0;i<odd.size();i++)
		{
			if (ans[odd[i].second]) continue;
			if (odd[i].first.second==1) continue;
			if (lst==-1)
			{
				lst=i;
				continue;
			}
			int tmp=(odd[i].first.first-odd[lst].first.first)>>1;
			//cout<<tmp<<"**"<<endl;
			ans[odd[i].second]=odd[lst].first.first+tmp;
			ans[odd[lst].second]=odd[lst].first.first+tmp;
			lst=-1;
		}
		lst=-1;
		for (int i=odd.size()-1;i>=0;i--)
		{
			if (ans[odd[i].second]) continue;
			if (odd[i].first.second==0) continue;
			if (lst==-1)
			{
				lst=i;
				continue;
			}
			int tmp=m-((odd[lst].first.first-odd[i].first.first)>>1);
			ans[odd[i].second]=-odd[i].first.first+tmp;
			ans[odd[lst].second]=-odd[i].first.first+tmp;
			lst=-1;
		}
		//cout<<"**"<<endl;
		//back to back
		int aa=-1,bb=-1;
		for (int i=0;i<odd.size();i++)
		{
			//cout<<i<<endl;
			if (ans[odd[i].second]) continue;
			if (aa==-1)
			{
				aa=i;
			}
			else
			{
				bb=i;
			}
		}
			
		if (bb==-1)
		{
		}
		else
		{
			int dd1=odd[aa].first.first,dd2=m-odd[bb].first.first;
			int taa=aa,tbb=bb;
			aa=odd[taa].first.first-min(dd1,dd2);
			bb=odd[tbb].first.first+min(dd1,dd2);
			ans[odd[taa].second]=min(dd1,dd2);
			ans[odd[tbb].second]=min(dd1,dd2);
			if (aa==0)
			{
				int tans=m-((bb-aa)>>1);
				ans[odd[taa].second]+=tans;
				ans[odd[tbb].second]+=tans;	
			}
			else
			{
				int tmp=(bb-aa)>>1;
				ans[odd[taa].second]+=aa+tmp;
				ans[odd[tbb].second]+=aa+tmp;
			}
		}
			
		//cout<<"**"<<endl;
		/////
		
		
		
		
		
		
		//////clide in begining
		for (int i=1;i<eve.size();i++)
		{
			if (eve[i].first.first==eve[i-1].first.first)
			{
				ans[eve[i].second]=0;
				ans[eve[i-1].second]=0;
				i++;
			}
		}
		//// face to face
		while (!st.empty())st.pop();
		for (int i=0;i<eve.size();i++)
		{
			if (ans[eve[i].second]) continue;
			if (eve[i].first.second==1)
			{
				st.push(i);
				continue;
			}
			if (st.empty())
			{
				continue;
			}
			int tp=st.top();
			st.pop();
			int tans=(eve[i].first.first-eve[tp].first.first)>>1;
			ans[eve[i].second]=tans;
			ans[eve[tp].second]=tans;
		}
		//cout<<"**"<<endl;
		////face to back
		//while (!st.empty())st.pop();
		lst=-1;
		for (int i=0;i<eve.size();i++)
		{
			if (ans[eve[i].second]) continue;
			if (eve[i].first.second==1) continue;
			if (lst==-1)
			{
				lst=i;
				continue;
			}
			int tmp=(eve[i].first.first-eve[lst].first.first)>>1;
			ans[eve[i].second]=eve[lst].first.first+tmp;
			ans[eve[lst].second]=eve[lst].first.first+tmp;
			lst=-1;
		}
		lst=-1;
		for (int i=eve.size()-1;i>=0;i--)
		{
			if (ans[eve[i].second]) continue;
			if (eve[i].first.second==0) continue;
			if (lst==-1)
			{
				lst=i;
				continue;
			}
			int tmp=m-((eve[lst].first.first-eve[i].first.first)>>1);
			ans[eve[i].second]=-eve[i].first.first+tmp;
			ans[eve[lst].second]=-eve[i].first.first+tmp;
			lst=-1;
		}
		//cout<<"**"<<endl;
		//back to back
		aa=-1;
		bb=-1;
		for (int i=0;i<eve.size();i++)
		{
			//cout<<i<<endl;
			if (ans[eve[i].second]) continue;
			if (aa==-1)
			{
				aa=i;
			}
			else
			{
				bb=i;
			}
		}
			
		if (bb==-1)
		{
		}
		else
		{
			int dd1=eve[aa].first.first,dd2=m-eve[bb].first.first;
			int taa=aa,tbb=bb;
			aa=eve[taa].first.first-min(dd1,dd2);
			bb=eve[tbb].first.first+min(dd1,dd2);
			ans[eve[taa].second]=min(dd1,dd2);
			ans[eve[tbb].second]=min(dd1,dd2);
			if (aa==0)
			{
				int tans=m-((bb-aa)>>1);
				ans[eve[taa].second]+=tans;
				ans[eve[tbb].second]+=tans;	
			}
			else
			{
				int tmp=(bb-aa)>>1;
				ans[eve[taa].second]+=aa+tmp;
				ans[eve[tbb].second]+=aa+tmp;
			}
		}
			
		for (int i=0;i<n;i++)
		{
			if (ans[i]==0)cout<<-1<<" ";
			else cout<<ans[i]<<" ";
			
		}
		cout<<endl;
	}
	return 0;
}

