#include <bits/stdc++.h>

// #define int ll
#define endl '\n'

using namespace std;

typedef long long ll;

void solve() {
#ifdef LOCAL
    cout << "____NEW_____" << endl;
#endif
    int t;
    cin >> t;
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        --a[i];
    }
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            a[i] = m - 1 - a[i] + m - 1;
        }
    }
    sort(a.begin(), a.end());
    a.push_back(a[0] + 2 * (m - 1));
    int cnt_even = 0;
    vector<int> diff;
    int even = 0;
    vector<int> da;
    for (int i = 0; i < n; i++) {
        if (a[i + 1] - a[i] != 0) {
            da.push_back(a[i]);
            diff.push_back(a[i + 1] - a[i] - 1);
            if ((a[i + 1] - a[i] - 1) % 2 == 0) {
                cnt_even++;
                even = a[i + 1] - a[i] - 1;
            }
        }
    }
    da.push_back(a[0] + 2 * (m - 1));
    if (cnt_even > 1) {
        cout << "No" << endl;
        return;
    } else {
        cout << "Yes" << endl;
    }
    if (t > 1) {
        sort(diff.begin(), diff.end());
        if (cnt_even) {
            cout << (cnt_even + 1) / 2 + 1 << endl;
        } else {
            cout << (diff.back() + 1) / 2 + 1 << endl;
        }
        if (t > 2) {
            cout << diff.size() - 1 << endl;
            if (diff.size() == 1)
                return;
            int cnt_cut = 0;
            vector<pair<int, int>> to_cut;
            for (int i = 0; i < diff.size(); i++) {
                int len = da[i + 1] - da[i] - 1;
                if (cnt_even && len % 2 == 0) {
                    cnt_cut++;
                    continue;
                }
                if (cnt_even == 0 && cnt_cut == 0 && len == diff.back()) {
                    cnt_cut++;
                    continue;
                }
                int tt = 0;
                if (a[i] <= m - 2 - len / 2)
                    tt = m - 2 - len / 2 - a[i];
                else
                    tt = 2 * (m - 1) - a[i] + m - 2 - len / 2;
                to_cut.push_back({tt, len});
            }
            sort(to_cut.begin(), to_cut.end());
            int curm = m - (to_cut[0].second + 1) / 2;
            int tt = to_cut[0].first;
            cout << tt << ' ' << m - (to_cut[0].second + 1) / 2 << endl;
            for (int i = 1; i < to_cut.size(); i++) {
                cout << tt + (to_cut[i].second + 1) / 2 << ' '
                     << curm - (to_cut[i].second + 1) / 2 << endl;
                // cout << to_cut[i].first - (m - curm) << ' '
                //      << curm - (to_cut[i].second + 1) / 2 << endl;
                curm -= (to_cut[i].second + 1) / 2;
                tt += (to_cut[i].second + 1) / 2;
            }
        }
    }
}

signed main() {
#ifdef LOCAL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int qwe = 1;
#ifdef LOCAL
    cin >> qwe;
#endif
    for (int _ = 0; _ < qwe; _++) {
        solve();
    }
}