//NeeD FoR AC!
#include <bits/stdc++.h>

using namespace std ;
 
typedef long long ll ;
typedef long double ld ;
typedef pair<ld ,int> pfi ;
typedef pair<int ,int> pii ; 
typedef pair<ll ,pii> pip ;

#define fast_io                ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define debug(x)               cerr << #x << " : " << x << endl
#define debugP(x ,y)           cerr << #x << "," << #y << " : " << x << "," << y << endl
#define here                   cerr << "here\n"
#define MP                     make_pair
#define F                      first
#define S                      second
 
constexpr int MAXN = 3e5 + 9 ;
constexpr int MOD = 1e9 + 9 ;
constexpr int INF = 1e9 + 9 ;
constexpr int LOG = 2e1 + 9 ;

int tc ,n ,m ,a[MAXN] ,ans[MAXN] ; 
char dir[MAXN] ; 
vector <int> vc ,l ,r ;  

bool cmp(int x ,int y){
	return a[x] < a[y] ; 
}

int main (){
	fast_io ;
	cin >> tc ; 
	while (tc--){
		cin >> n >> m ; 
		for (int i = 1; i <= n; i++){
			cin >> a[i] ; 
		}
		for (int i = 1; i <= n; i++){
			cin >> dir[i] ;
		}
		for (int i = 1; i <= n; i++){
			if (a[i] & 1){
				vc.push_back(i) ; 
			}
		}
		sort(vc.begin() ,vc.end() ,cmp) ;
		for (auto idx : vc){
			if (dir[idx] == 'R'){
				r.push_back(idx) ; 
			}
			else {
				if (r.empty()){
					l.push_back(idx) ; 
				}
				else {
					int idx1 = r.back() ; 
					r.pop_back() ;  
					int t = abs(a[idx1] - a[idx]) / 2 ; 
					ans[idx1] = t ; 
					ans[idx] = t ; 
				}
			}
		}
		int len = r.size() ; 
		int right = 0 ; 
		if (!(len & 1)){
			for (int i = 0; i < len; i += 2){
				int idx1 = r[i] ,idx2 = r[i + 1] ; 
				int t = m - a[idx2] + abs(a[idx1] - a[idx2]) / 2 ; 
				ans[idx1] = t ; 
				ans[idx2] = t ; 
			}
		}
		else {
			right = r[0] ; 
			for (int i = 1; i < len; i += 2){
				int idx1 = r[i] ,idx2 = r[i + 1] ; 
				int t = m - a[idx2] + abs(a[idx1] - a[idx2]) / 2 ; 
				ans[idx1] = t ; 
				ans[idx2] = t ; 
			}
		}
		len = l.size() ; 
		int left = 0 ; 
		if (!(len & 1)){
			for (int i = 0; i < len; i += 2){
				int idx1 = l[i] ,idx2 = l[i + 1] ; 
				int t = a[idx1] + abs(a[idx1] - a[idx2]) / 2 ; 
				ans[idx1] = t ; 
				ans[idx2] = t ; 
			}
		}
		else {
			reverse(l.begin() ,l.end()) ; 
			left = l[0] ; 
			for (int i = 1; i < len; i += 2){
				int idx1 = l[i] ,idx2 = l[i + 1] ; 
				int t = a[idx2] + abs(a[idx1] - a[idx2]) / 2 ; 
				ans[idx1] = t ; 
				ans[idx2] = t ; 
			}
		}
		if (left && right){
			int mx = max(m - a[right] ,a[left]) ; 
			int posleft = -(a[left] - mx) ;
			int posright = a[right] + mx ;
			if (posright > m){
				posright = m - (posright - m) ; 
			}
			int t = mx + abs(posright - posleft) / 2 ; 
			ans[left] = t ; 
			ans[right] = t ; 
		}
		else {
			ans[left] = -1 ;
			ans[right] = -1 ; 
		}
		vc.clear() ; 
		l.clear() ; 
		r.clear() ; 
		for (int i = 1; i <= n; i++){
			if (!(a[i] & 1)){ 
				vc.push_back(i) ; 
			}
		}
		sort(vc.begin() ,vc.end() ,cmp) ;
		for (auto idx : vc){
			if (dir[idx] == 'R'){
				r.push_back(idx) ; 
			}
			else {
				if (r.empty()){
					l.push_back(idx) ; 
				}
				else {
					int idx1 = r.back() ; 
					r.pop_back() ; 
					int t = abs(a[idx1] - a[idx]) / 2 ; 
					ans[idx1] = t ; 
					ans[idx] = t ; 
				}
			}
		}
		len = r.size() ; 
		right = 0 ; 
		if (!(len & 1)){
			for (int i = 0; i < len; i += 2){
				int idx1 = r[i] ,idx2 = r[i + 1] ; 
				int t = m - a[idx2] + abs(a[idx1] - a[idx2]) / 2 ; 
				ans[idx1] = t ; 
				ans[idx2] = t ; 
			}
		}
		else {
			right = r[0] ; 
			for (int i = 1; i < len; i += 2){
				int idx1 = r[i] ,idx2 = r[i + 1] ; 
				int t = m - a[idx2] + abs(a[idx1] - a[idx2]) / 2 ; 
				ans[idx1] = t ; 
				ans[idx2] = t ; 
			}
		}
		len = l.size() ; 
		left = 0 ; 
		if (!(len & 1)){
			for (int i = 0; i < len; i += 2){
				int idx1 = l[i] ,idx2 = l[i + 1] ; 
				int t = a[idx1] + abs(a[idx1] - a[idx2]) / 2 ; 
				ans[idx1] = t ; 
				ans[idx2] = t ; 
			}
		}
		else {
			reverse(l.begin() ,l.end()) ; 
			left = l[0] ; 
			for (int i = 1; i < len; i += 2){
				int idx1 = l[i] ,idx2 = l[i + 1] ; 
				int t = a[idx2] + abs(a[idx1] - a[idx2]) / 2 ; 
				ans[idx1] = t ; 
				ans[idx2] = t ; 
			}
		}
		if (left && right){
			int mx = max(m - a[right] ,a[left]) ; 
			int posleft = -(a[left] - mx) ;
			int posright = a[right] + mx ;
			if (posright > m){
				posright = m - (posright - m) ; 
			}
			int t = mx + abs(posright - posleft) / 2 ; 
			ans[left] = t ; 
			ans[right] = t ; 
		}
		else {
			ans[left] = -1 ;
			ans[right] = -1 ; 
		}
		for (int i = 1; i <= n; i++){
			cout << ans[i] << " " ; 
			ans[i] = 0 ; 
		}
		cout << "\n" ; 
		vc.clear() ; 
		l.clear() ; 
		r.clear() ; 
	}
	return 0 ;
}

