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

#define rep(i, n) for (int i = 0; i < (n); i += 1)
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define len(a) (int)((a).size())



int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    int n, m;
    cin >> n >> m;
    vector<int> vec(n);
    for (auto &c : vec) cin >> c;
    string s;
    cin >> s;
    for (int i = 0; i < n; ++i) {
        --vec[i];
        if (vec[i] % 2 != vec[0] % 2) {
            cout << "NO\n";
            return 0;
        }
    }

    cout << "YES\n";
    vector<int> cords;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') {
            cords.push_back(vec[i]);
        } else {
            cords.push_back((m - 1) + (m - vec[i] - 1));
        }
    }
    sort(all(cords));
    int ans = 0;
    pair<int, int> mx = {-1, -1};
    for (int i = 0; i < len(cords); ++i) {
        int d = cords[(i + 1) % len(cords)] - cords[i];
        if (d < 0) d += 2 * (m - 1);
        ans += d / 2;
        mx = max(mx, {d, i});
    }

    ans -= mx.first / 2;
    if (t == 2 || t == 3) {
        cout << m - ans << "\n";
    }
    vector<pair<int, int>> seq;
    int curm = m;
    int tm = ((m - 1) - cords[mx.second] + 2 * (m - 1)) % (2 * (m - 1));
    for (int i = 0; i + 1 < len(cords); ++i) {
        int curi = (mx.second - i - 1 + len(cords)) % (len(cords));
        int d = cords[(curi + 1) % len(cords)] - cords[curi];
        if (d < 0) d += 2 * (m - 1);
        tm += d / 2;
        if (d / 2) seq.push_back({tm, curm - d / 2});
        curm -= d / 2;
    }


    if (t == 3) {
        cout << len(seq) << "\n";
        for (auto c : seq) cout << c.first << " " << c.second << "\n";
    }


    return 0;
} 
