#pragma GCC optimize("O3,unroll-loops")
#include <vector>
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int t;
    cin >> t;
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for (auto& i : a) {
        cin >> i;
        i--;
    }
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') a[i] = 2 * m - 2 - a[i];
    }
    for (int i = 0; i < n; i++) if (a[i] % 2 != a[(i + 1) % n] % 2) {
        cout << "No\n";
        return 0;
    }
    sort(a.begin(), a.end());
    ll p = 2 * m - 2;
    ll mxdist = a[0] - a.back() + p;
    int mxi = 0;
    for (int i = 0; i < n - 1; i++) {
        if (mxdist < a[i + 1] - a[i]) {
            mxdist = a[i + 1] - a[i];
            mxi = i + 1;
        }
    }
    cout << "Yes\n";
    if (t == 2 || t == 3) cout << mxdist / 2 + 1 << "\n";
    if (t == 3) {
        vector<int> dst(n - 1);
        for (int di = 0; di < n - 1; di++) {
            dst[di] = (a[(mxi + di + 1) % n] - a[(mxi + di) % n] + p) % p;
        }
        vector<pair<ll, ll>> ans;
        ll t = 0;
        ll pos = a[mxi];
        ll sz = m;
        for (int i = 0; i < n; i++) {
            if (dst[i] == 0) continue;
            int k = dst[i] / 2;
            int p = sz * 2 - 2;
            t += (sz - 1 - k - pos + p) % p;
            sz -= k;
            pos = sz - 1;
            ans.push_back({t, sz});
        }
        cout << ans.size() << "\n";
        for (auto [i, j] : ans) {
            cout << i << " " << j << "\n";
        }
    }
}