#include <bits/stdc++.h>
using namespace std;

const int maxn = 300000 + 5;

struct Robot {
	int x, id;
	char dir;
	bool operator<(const Robot& rhs) const {
		return x < rhs.x;
	}
};

int n, m;
Robot a[maxn];

void solve() {
	sort(a, a+n);
	vector<int> ans(n, -1);

	stack<Robot> stk[2];
	for (int i = 0; i < n; i++) {
		int p = a[i].x % 2;
		if (a[i].dir == 'L') {
			if (stk[p].empty()) stk[p].push(a[i]);
			else {
				Robot lastRobot = stk[p].top(); stk[p].pop();
				if (lastRobot.dir == 'L') {
					ans[lastRobot.id] = ans[a[i].id] = (lastRobot.x + a[i].x) / 2;
				} else {
					ans[lastRobot.id] = ans[a[i].id] = (a[i].x - lastRobot.x) / 2;
				}
			}
		} else {
			stk[p].push(a[i]);
		}
	}

	for (int p = 0; p < 2; p++) {
		stack<Robot> &s = stk[p];
		while (s.size() >= 2) {
			Robot firstRobot = s.top(); s.pop();
			Robot secondRobot = s.top(); s.pop();
			ans[firstRobot.id] = ans[secondRobot.id] = (2*m - firstRobot.x - (secondRobot.dir == 'L' ? -secondRobot.x : secondRobot.x)) / 2;
		}
	}

	for (int i = 0; i < n; i++) cout << ans[i] << " ";
	cout << "\n";
}

int main() {
	int T;
	cin >> T;
	while (T--) {
		cin >> n >> m;
		for (int i = 0; i < n; i++) {
			cin >> a[i].x;
			a[i].id = i;
		}
		for (int i = 0; i < n; i++) {
			cin >> a[i].dir;
		}
		solve();
	}
	return 0;
}