#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll p = 1e9 + 7;
const ll nax = 100001;

int main() {
	int t;
	cin >> t;
	while (t--) {
		int n, m;
		cin >> n >> m;
		set<pair<int, pair<int, char>>> st[2];
		vector<int> ans(n, -1), a(n);
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
		}
		for (int i = 0; i < n; ++i) {
			char c;
			cin >> c;
			st[a[i] % 2].insert({a[i], {i, c}});
		}
		for (int k = 0; k < 2; ++k) {
			deque<pair<int, char>> s;
			for (auto& [x, y] : st[k]) {
				// cout << k << ' ' << y.first << endl;
				if (s.empty() || !(s.back().second == 'R' && y.second == 'L')) {
					s.push_back(y);
					// cout << "ADD\n";
				} else {
					ans[s.back().first] = ans[y.first] = (a[y.first] - a[s.back().first]) / 2;
					s.pop_back();
				}
			}
			while (s.size() > 1 && s[0].second == s[1].second && s[0].second == 'L') {
				ans[s[0].first] = ans[s[1].first] = a[s[0].first] + (a[s[1].first] - a[s[0].first]) / 2;
				s.pop_front();
				s.pop_front();
			}
			while (s.size() > 1 && s[s.size() - 1].second == s[s.size() - 2].second) {
				ans[s[s.size() - 1].first] = ans[s[s.size() - 2].first] = m - a[s[s.size() - 1].first] + (a[s[s.size() - 1].first] - a[s[s.size() - 2].first]) / 2;
				s.pop_back();
				s.pop_back();
			}
			if (s.size() > 1) {
				ans[s[0].first] = ans[s[1].first] = (m + a[s[0].first] + (m - a[s[1].first])) / 2;
			}
		}
		for (auto& x : ans) {
			cout << x << ' ';
		}
		cout << '\n';
	}
	return 0;
}