#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <deque>
#include <unordered_map>
#include <map>
#include <queue>
#include <cassert>
using namespace std;

typedef long long ll;
typedef long double ld;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define INF 1e10;


ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a % b);
}

bool is_sorted(vector<ll>& a) {
	bool sorted = true;
	for (ll i = 0; i < a.size() && sorted; i++) {
		if (a[i] != i + 1)
			sorted = false;
	}
	return sorted;
}

vector<ll> sort_part(vector<ll> a, int t) {
	if (t == 1) { // [0, n - 1)
		sort(begin(a), end(a) - 1);
	}
	else { // (0, n - 1]
		sort(begin(a) + 1, end(a));
	}

	return a;
}

ll solve(vector<ll>& a, int cnt, int res, int t) {
	if (is_sorted(a)) {
		return min(cnt, res);
	}

	if (t != 1) {
		vector<ll> a1 = sort_part(a, 1);
		res = solve(a1, cnt + 1, res, 1);
	}
	
	if (t != 2) {
		t = 2;
		vector <ll> a2 = sort_part(a, 2);
		res = solve(a2, cnt + 1, res, 2);
	}

	return res;
}


int find_closest(vector<int>& places, int ind) {
	int l = 0, r = places.size();
	
	while (r - l > 2) {
		int m1 = (r + 2 * l) / 3;
		int m2 = (2 * r + l) / 3;
		
		if (abs(ind - places[m1]) > abs(ind - places[m2])) {
			l = m2;
		}
		else {
			r = m1;
		}
	}

	int ans = l;
	for (int p = l; p <= min(r, (int)places.size() - 1); p++) {
		if (abs(ind - places[ans]) > abs(ind - places[p]))
			ans = p;
	}

	return ans;
}

struct robot {
	int x;
	char d;
	int ind;

	robot() {
		ind = x = -1;
		d = '-';
	}

	robot(int _x, char _d, int _ind) {
		d = _d;
		x = _x;
		ind = _ind;
	}
};

int count_time(robot& r1, robot& r2, int m) {
	if (r1.x > r2.x) swap(r1, r2);
	// r1.x < r2.x

	int res = 0;
	if (r1.d == r2.d) {
		if (r1.d == 'R') {
			res = abs(r1.x - r2.x) / 2 + m - max(r1.x, r2.x);
		}
		else {
			res = abs(r1.x - r2.x) / 2 + min(r1.x, r2.x);
		}
	}
	else if(r1.d == 'L' && r2.d == 'R') {
		res = abs(r1.x - r2.x) / 2 + min(r1.x, r2.x) + m - max(r1.x, r2.x);
	}
	else {
		res = abs(r1.x - r2.x) / 2;
	}

	return res;
}


void process(vector<robot>& arr, vector<int>& res, int m) {
	vector<robot> st;

	for (int i = 0; i < arr.size(); i++) {
		if (arr[i].d == 'L' && (st.size() && st.back().d == 'R')) {
			int t = count_time(arr[i], st.back(), m);
			res[arr[i].ind] = res[st.back().ind] = t;
			st.pop_back();
		}
		else {
			st.push_back(arr[i]);
		}
	}

	int processed = 0;

	int ind = 0;
	while (ind + 1 < st.size() && st[ind + 1].d == 'L') {
		robot r1 = st[ind], r2 = st[ind + 1];
		
		int t = count_time(r1, r2, m);
		res[r1.ind] = res[r2.ind] = t;

		ind += 2;
		processed += 2;
		//st.erase(begin(st));
		//st.erase(begin(st));
	}

	//int k = st.size();
	ind = st.size() - 1;

	while (ind - 1 >= 0 && st[ind - 1].d == 'R') {
		robot r1 = st[ind], r2 = st[ind - 1];
		
		int t = count_time(r1, r2, m);
		res[r1.ind] = res[r2.ind] = t;

		ind -= 2;
		processed += 2;
		//st.erase(st.begin() + k - 1);
		//k = st.size();
		//st.erase(st.begin() + k - 1);
		//k = st.size();
	}

	if (processed + 2 == st.size()) {
		ind = -1;
		for (int i = 1; i < st.size(); i++) {
			if (st[i - 1].d == 'L' && st[i].d == 'R') {
				ind = i - 1;
				break;
			}
		}

		robot r1 = st[ind], r2 = st[ind + 1];
		int t = count_time(r1, r2, m);

		res[r1.ind] = res[r2.ind] = t;
	}

	/*if (st.size() > 1) {
		robot r1 = st[0], r2 = st[1];
		int t = count_time(r1, r2, m);
		res[r1.ind] = res[r2.ind] = t;

		st.erase(begin(st));
		st.erase(begin(st));
	}*/

	//assert(st.size() <= 1);
}


bool comp(robot& r1, robot& r2) {
	return r1.x < r2.x;
}


int main() {
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");

	int t; cin >> t;

	while (t--) {
		int n, m;
		cin >> n >> m;

		vector<int> a(n);
		vector<char> d(n);

		forn(i, n)
			cin >> a[i];
		forn(i, n)
			cin >> d[i];

		vector<robot> evens;
		vector<robot> odds;

		evens.reserve(n);
		odds.reserve(n);


		for (int i = 0; i < n; i++) {
			if (a[i] % 2) {
				// odd
				odds.push_back(robot(a[i], d[i], i));
			}
			else {
				// even
				evens.push_back(robot(a[i], d[i], i));
			}
		}

		sort(evens.begin(), evens.end(), comp);
		sort(odds.begin(), odds.end(), comp);

		vector<int> res(n, -1);
		process(evens, res, m);
		process(odds, res, m);

		for (int el : res)
			cout << el << " ";
		cout << endl;
	}

	return 0;
}