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

#define MX 300050
#define x first
#define dir second
pair<int, int> a[MX];
int res[MX];
int id[MX];

int main() {
	int tc; scanf("%d", &tc);
	while (tc--) {
		int n, m; scanf("%d%d", &n, &m);
		stack<int> s[2][2];
		for (int i = 1; i <= n; i++) scanf("%d", &a[i].x);
		for (int i = 1; i <= n; i++) {
			char s[3]; scanf("%s", s);
			a[i].dir = (s[0] == 'L' ? 0 : 1);
			id[i] = i; res[i] = -1;
		}
		sort (id + 1, id + n + 1, [&] (int i, int j) { return a[i] < a[j]; });
		sort(a + 1, a + n + 1);
		for (int i = 1; i <= n; i++) {
			if (!a[i].dir && s[a[i].x & 1][1].size()) {
				int p = s[a[i].x & 1][1].top();
				s[a[i].x & 1][1].pop();
				res[id[i]] = res[id[p]] = abs(a[i].x - a[p].x) / 2;
			}
			else s[a[i].x & 1][a[i].dir].push(i);
		}
		for (int i = 0; i < 2; i++) {
			while (s[i][1].size() > 1) {
				int p1 = s[i][1].top(); s[i][1].pop();
				int p2 = s[i][1].top(); s[i][1].pop();
				assert (a[p1].x > a[p2].x);
				res[id[p1]] = res[id[p2]] = (a[p1].x - a[p2].x) / 2 + m - a[p1].x;
			}
			vector<int> tmp;
			while (s[i][0].size()) {
				tmp.push_back(s[i][0].top()); s[i][0].pop();
			}
			for (auto it : tmp) s[i][0].push(it);
			while (s[i][0].size() > 1) {
				int p1 = s[i][0].top(); s[i][0].pop();
				int p2 = s[i][0].top(); s[i][0].pop();
				assert (a[p1].x < a[p2].x);
				res[id[p1]] = res[id[p2]] = (a[p2].x - a[p1].x) / 2 + a[p1].x;
			}
			if (s[i][0].size() && s[i][1].size()) {
				int p1 = s[i][0].top(); s[i][0].pop();
				int p2 = s[i][1].top(); s[i][1].pop();
				res[id[p1]] = res[id[p2]] = (2 * m - a[p2].x + a[p1].x) / 2;
			}
		}
		for (int i = 1; i <= n; i++) printf("%d ", res[i]);
		puts("");
	}
	return 0;
}
