// TaskB.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <map>

using namespace std;

using ll = long long;
using ld = long double;

const ll inf = 1e18 + 7;
const ll mod = 1e9 + 7;

ll t;
ll n, m;
vector<ll> a;
vector<ll> ar;

ll cnt0(ll p, ll d) {
	if (p == m - 1 && d == 0) {
		return 0;
	}
	if (d == 1) {
		return m - p - 1;
	}
	return p * 2 + m - p - 1;
}

ll mx = 0;
ll xt = 0;
ll curt = 0;

void xmove(ll &p, ll &d, ll &cnt) {
	if (p == 0) {
		d = 1;
	}
	if (p == m - 1) {
		d = 0;
	}
	if (d == 0) {
		if (cnt <= p) {
			p -= cnt;
		}
		else {
			cnt -= p;
			p = 0;
			xmove(p, d, cnt);
		}
	}
	else {
		if (cnt <= m - p - 1) {
			p += cnt;
		}
		else {
			cnt -= m - p - 1;
			p = m - 1;
			xmove(p, d, cnt);
		}
	}
	if (p == 0) {
		d = 1;
	}
	if (p == m - 1) {
		d = 0;
	}
}

void move(ll cnt) {
	curt += cnt;
	cnt %= (m * 2 - 2);
	for (ll i = 0; i < n; i++) {
		ll ncnt = cnt;
		xmove(a[i], ar[i], ncnt);
	}
}

ll getcnt(ll p1, ll d1, ll p2, ll d2) {
	if (p1 > p2) {
		swap(p1, p2);
		swap(d1, d2);
	}
	if (p1 == p2) {
		return 0;
	}
	ll ans = 0;
	if (d1 == 0) {
		ll cnt = p1;
		ans += cnt;
		xmove(p1, d1, cnt);
		xmove(p2, d2, cnt);
	}
	if (d2 == 1) {
		ll cnt = m - p2;
		ans += cnt;
		xmove(p1, d1, cnt);
		xmove(p2, d2, cnt);
	}
	ans += (p2 - p1) / 2;
	return ans;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> t;
	cin >> n >> m;
	a.resize(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	string s;
	cin >> s;
	ar.resize(n);
	for (ll i = 0; i < n; i++) {
		ar[i] = (s[i] == 'R');
	}
	vector<pair<ll, ll>> xd(n);
	ll val0 = cnt0(a[0], ar[0]) % 2;
	for (ll i = 0; i < n; i++) {
		if (cnt0(a[i], ar[i]) % 2 != val0) {
			cout << "No" << '\n';
			return 0;
		}
		xd[i] = { cnt0(a[i], ar[i]), i };
	}
	cout << "Yes" << '\n';
	sort(xd.begin(), xd.end());
	ll last = m - 1;
	move(xd[0].first);
	vector<pair<ll, ll>> ans;
	vector<ll> used(n);
	used[xd[0].second] = 1;
	for (ll i = 0; i < n - 1; i++) {
		ll ind = -1;
		ll indval = inf;
		for (ll j = 0; j < n; j++) {
			if (used[j] == 1) {
				continue;
			}
			if (cnt0(a[j], ar[j]) < indval) {
				ind = j;
				indval = cnt0(a[j], ar[j]);
			}
		}
		ll cnt = getcnt(last, 0, a[ind], ar[ind]);
		if (cnt == 0) {
			continue;
		}
		ll p = last;
		ll xd = 0;
		xmove(p, xd, cnt);
		if (p < m / 2) {
			p = m - p - 1;
			cnt += m - 1;
		}
		move(cnt);
		ans.push_back({ curt, p + 1 });
		m = p + 1;
		last = m - 1;
		used[ind] = 1;
	}
	if (t >= 2) {
		cout << m << '\n';
	}
	if (t >= 3) {
		cout << ans.size() << '\n';
		for (pair<ll, ll> par : ans) {
			cout << par.first << ' ' << par.second << '\n';
		}
	}
}
