#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <random>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
using ll = long long;
using ld = long double;

const int inf = 1e9 + 10;

void add_time(int& pos, int& dir, int t, const int m) {
	t %= (m - 1) * 2;
	if (dir) {
		if (t >= m - 1 - pos) {
			pos = m - 1 - (t - m + 1 + pos);
			dir = 0;
			if (pos <= 0) {
				dir = 1;
				pos = -pos;
			}
			return;
		}
		else {
			pos += t;
			return;
		}
	}
	else {
		if (t >= pos) {
			pos = t - pos;
			dir = 1;
			if (pos >= m - 1) {
				pos = (m - 1) * 2 - pos;
				dir = 0;
			}
			return;
		}
		else {
			pos -= t;
			return;
		}
	}
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int T, n, m;
	cin >> T >> n >> m;
	vector<int> a(n);
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
		if (i > 0 && a[i] % 2 != a[i - 1] % 2) {
			cout << "No";
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		char c;
		cin >> c;
		d[i] = (c == 'R');
	}
	cout << "Yes\n";
	if (T == 1)
		return 0;

	bool fl2 = 1;
	for (int i = 1; i < n; i++)
		if (a[i] != a[i - 1] || d[i] != d[i - 1])
			fl2 = 0;
	if (fl2) {
		cout << m << '\n';
		if (T == 3)
			cout << 0 << '\n';
		return 0;
	}

	int m0 = m;
	ll t = 0;
	vector<pair<ll, int>> ans;
	set<int> stl, str;
	for (int i = 0; i < n; i++) {
		if (a[i] == 0)
			d[i] = 1;
		if (a[i] == m - 1)
			d[i] = 0;
		if (d[i] == 1)
			str.insert(a[i]);
		else
			stl.insert(a[i]);
	}
	while (stl.size() + str.size() > 1) {
		int maxp = -1;
		int ati = 1;

		// 11
		if (str.size() > 1){
			for (auto y : str) {
				if (str.lower_bound(y) == str.begin())
					continue;
				const int x = *(--str.lower_bound(y));
				if (maxp < (x - y) / 2 + m - 1) {
					maxp = (x - y) / 2 + m - 1;
					ati = maxp - x;
				}
			}
			const int y = *(--str.end());
			const int x = *(str.begin());
			if (x < y && maxp < (y - x) / 2) {
				maxp = (y - x) / 2;
				ati = (m - 1) * 2 - x - maxp;
			}
		}
		//10
		if (stl.size() > 0 && str.size() > 0) {
			const int y = *(--stl.end());
			if (str.upper_bound(y) != str.begin()) {
				const int x = *(--str.upper_bound(y));
				if (maxp < (x + y) / 2) {
					maxp = (x + y) / 2;
					ati = maxp - x;
				}
				if (maxp < m - 1 - (x + y) / 2) {
					maxp = m - 1 - (x + y) / 2;
					ati = (m - 1) * 2 - x - maxp;
				}
			}
		}
		//01
		if (stl.size() > 0 && str.size() > 0) {
			const int y = *(--str.end());
			if (stl.upper_bound(y) != stl.begin()) {
				const int x = *(--stl.upper_bound(y));
				if (maxp < m - 1 - (x + y) / 2) {
					maxp = m - 1 - (x + y) / 2;
					ati = maxp + x;
				}
				if (maxp < (x + y) / 2) {
					maxp = (x + y) / 2;
					ati = x - maxp + (m - 1) * 2;
				}
			}
		}
		//00
		if (stl.size() > 1) {
			for (auto y : stl) {
				if (stl.lower_bound(y) == stl.begin())
					continue;
				const int x = *(--stl.lower_bound(y));
				if (maxp < m - 1 + (x - y) / 2) {
					maxp = m - 1 + (x - y) / 2;
					ati = x - maxp + (m - 1) * 2;
				}
			}
			const int y = *(--stl.end());
			const int x = *(stl.begin());
			if (x < y && maxp < (y - x) / 2) {
				maxp = (y - x) / 2;
				ati = maxp + x;
			}
		}
		maxp++;

		bool fl = 1;
		for (int i = 0; i < n; i++) {
			add_time(a[i], d[i], ati, m);
			if (a[i] == 0)
				d[i] = 1;
			if (a[i] == maxp - 1)
				d[i] = 0;
			if (d[i] == 1)
				str.insert(a[i]);
			else
				stl.insert(a[i]);
			if (i > 0 && (a[i] != a[i - 1] || d[i] != d[i - 1]))
				fl = 0;
		}
		t += ati;
		if (maxp < m)
			ans.push_back({ t, maxp });
		m = maxp;
		if (fl)
			break;
	}
	cout << m << '\n';
	if (T == 2)
		return 0;
	cout << ans.size() << '\n';
	for (auto p : ans)
		cout << p.first << ' ' << p.second << '\n';
}
