#include <bits/stdc++.h>

#define int long long

using namespace std;

using pii = pair<int, int>;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int T;
    cin >> T;
    int n, m;
    cin >> n >> m;
    int m0 = m;
    vector<int> b(n), a(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        b[i]--;
        a[i] = b[i];
    }
    string s;
    cin >> s;

    bool ok = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 != a[0] % 2) {
            ok = 0;
        }
    }

    if (!ok) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";

    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            a[i] = -a[i];
        }
        a[i] += 2 * m - 2;
        a[i] /= 2;
        a[i] %= m - 1;
    }

    sort(a.begin(), a.end());

    int sv = a[0] - a[n - 1] + m - 1, svin = n - 1;
    for (int i = 0; i < n - 1; i++) {
        if (a[i + 1] - a[i] > sv) {
            sv = a[i + 1] - a[i];
            svin = i;
        }
    }

    if (T >= 2) {
        cout << sv + 1 << "\n";
    }

    vector<pii> ans;
    int t = 0;
    for (int i = (svin + 1) % n; i != svin; i = (i + 1) % n) {
        int l = a[i], cnt = a[(i + 1) % n] - a[i % n];
        if (cnt == 0) continue;
        if (cnt < 0) cnt += m - 1;
        int l0 = (l * 2) % (2 * m - 2);
        int goal = m - 1 - cnt;
        int d = goal - l0;
        if (d < 0) d += 2 * m - 2;
        m -= cnt;
        ans.push_back({t + d, m});
        t += 2 * (m + cnt) - 2;
    }

    if (b[0] % 2 == 1) {
        for (int i = 0; i < ans.size(); i++) {
            ans[i].first += 2 * m0 - 3;
        }
    }

    if (T >= 3) {
        cout << ans.size() << "\n";
        for (auto [x, y] : ans) {
            cout << x << " " << y << "\n";
        }
    }
}
