#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define all(a) a.begin(), a.end()

void solve();

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
#ifdef LOCAL
    cin >> t;
#else
#endif
    while (t--) solve();
}

void solve() {
    ll t, n, m;
    cin >> t >> n >> m;
    vector<ll> a(n);
    string s;
    for (ll i = 0; i < n; i++) cin >> a[i];
    cin >> s;
    set<ll> f;
    for (ll i = 0; i < n; i++) {
        ll x = 0;
        if (a[i] == 1) x = 0;
        else if (a[i] == m) x = m - 1;
        else if (s[i] == 'R') x = a[i] - 1;
        else x = 2 * m - 1 - a[i];
        f.insert(x);
    }
    vector<ll> nchs, chs;
    vector<ll> u(all(f));
    u.push_back(u[0] + (2 * m - 2));
    for (ll i = 0; i + 1 < u.size(); i++) {
        ll x = u[i + 1] - u[i] - 1;
        if (x % 2 == 1) nchs.push_back(x);
        else chs.push_back(x);
    }
    sort(all(nchs));
    string res1;
    ll res2;
    if (chs.size() == 1) res1 = "Yes", res2 = chs[0] + 1;
    else if (chs.size() == 0) res1 = "Yes", res2 = nchs.back() + 1;
    else res1 = "No", res2 = -1;
    cout << res1 << "\n";
    if (t >= 2 && res1 == "Yes") {
        cout << (res2 + 2) / 2 << "\n";
    }
    if (t >= 3 && res1 == "Yes") {
        ll x = -1;
        for (ll i = 0; i + 1 < u.size(); i++) {
            if (u[i + 1] - u[i] == res2) {
                x = u[i];
                break;
            }
        }
        u.pop_back();
        ll s = m, t = (m - 1) - x + (2 * m - 2);
        for (ll i = 0; i < u.size(); i++) {
            u[i] = (u[i] + t) % (2 * m - 2);
            if (u[i] >= m) u[i] -= (2 * m - 2);
        }
        sort(all(u));
        cout << (ll) u.size() - 1 << "\n";
        for (ll i = (ll) u.size() - 2; i >= 0; i--) {
            ll d = (u[i + 1] - u[i]) / 2;
            t += d, s -= d;
            cout << t << " " << s << "\n";
        }
    }
    cout << "\n";
}
