#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <array>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <chrono>
#include <valarray>
#include <bitset>
using ll = long long;
using std::cin;
using std::cout;
using std::endl;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

void solve()
{
	int n; cin >> n;
	ll m; cin >> m;
	std::vector<std::tuple<ll, char, int>> even, odd;
	std::vector<ll> x(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n; ++i)
	{
		char c; cin >> c;
		if(x[i] % 2 == 0)
		{
			even.emplace_back(x[i], c, i);
		}
		else
		{
			odd.emplace_back(x[i], c, i);
		}
	}
	std::vector<ll> res(n);
	auto calc = [&](std::vector<std::tuple<ll, char, int>> &vt)
	{
		std::sort(vt.begin(), vt.end());
		std::vector<std::pair<ll, int>> L, R;
		for(const auto &[x, dir, id] : vt)
		{
			if(dir == 'L')
			{
				if(R.empty())
				{
					if(L.empty())
					{
						L.emplace_back(x, id);
					}
					else
					{
						ll t = L.back().first;
						ll cx = x - t;
						t += cx / 2;
						res[L.back().second] = res[id] = t;
						L.pop_back();
					}
				}
				else
				{
					ll t = (x - R.back().first) / 2;
					res[R.back().second] = res[id] = t;
					R.pop_back();
				}
			}
			else
			{
				R.emplace_back(x, id);
			}
		}
		while((int)R.size() >= 2)
		{
			auto [x1, id1] = R.back();
			R.pop_back();
			auto [x2, id2] = R.back();
			R.pop_back();
			ll t = m - x1;
			ll cx = x2 + t;
			ll dif = m - cx;
			t += dif / 2;
			res[id1] = res[id2] = t;
		}
		if(not R.empty() and not L.empty())
		{
			ll len = R.back().first - L.back().first;
			len = m * 2 - len;
			ll t = len / 2;
			res[R.back().second] = res[L.back().second] = t;
			R.pop_back();
			L.pop_back();
		}
		if(not R.empty())
		{
			res[R.back().second] = -1;
			R.pop_back();
		}
		if(not L.empty())
		{
			res[L.back().second] = -1;
			L.pop_back();
		}
	};
	calc(even);
	calc(odd);
	for (int i = 0; i < (int)res.size(); ++i)
	{
		cout << res[i] << " \n"[i + 1 == (int)res.size()];
	}
}
int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int kkt = 1;
  cin >> kkt;
  while(kkt--)
    solve();
  return 0;
}