// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(x) x.begin(), x.end()

// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

vector<int> time_inters = {};

bool cmp_time(int ind1, int ind2) {
    return make_pair(time_inters[ind1], ind1) < make_pair(time_inters[ind2], ind2);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    int n, m, cur_rem;
    cin >> n >> m;
    vector<int> a(n);
    cur_rem = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (cur_rem == -1) {
            cur_rem = a[i] % 2;
        } else {
            if (cur_rem != a[i] % 2) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    string dir;
    cin >> dir;
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++) {
        a[i]--;
        if (dir[i] == 'R') {
            time_inters.push_back((m - 1 - a[i]));
        } else {
            if (a[i] == m - 1) {
                time_inters.push_back(0);
            } else {
                time_inters.push_back(a[i] + m - 1);
            }
        }
    }
    vector<int> indexes_inters = {};
    vector<int> time_inters_source = time_inters;
    for (int i = 0; i < n; i++) {
        indexes_inters.push_back(i);
    }
    sort(all(indexes_inters), cmp_time);
    sort(all(time_inters));
    int ans = 0;
    int max_ans = -1;
    int ind_max = -1;
    for (int i = 1; i < n; i++) {
        ans += (time_inters[i] - time_inters[i - 1]) / 2;
        if ((time_inters[i] - time_inters[i - 1]) / 2 > max_ans) {
            max_ans = (time_inters[i] - time_inters[i - 1]) / 2;
            ind_max = i;
        }
//        cout << time_inters[i] << " ";
    }
//    cout << endl;
    ans += (time_inters[0] - time_inters[n - 1] + 2 * m - 2) / 2;
    if ((time_inters[0] - time_inters[n - 1] + 2 * m - 2) / 2 > max_ans) {
        max_ans = (time_inters[0] - time_inters[n - 1] + 2 * m - 2) / 2;
        ind_max = n;
    }
    if (t == 1) {
        return 0;
    }
    cout << m - ans + max_ans << endl;
    if (t == 2) {
        return 0;
    }
    int cur_t = 0;
    vector<pair<int, int>> print_ans = {};
    vector<int> new_ind_inters = {};
    if (ind_max == n) {
        new_ind_inters = indexes_inters;
    }
    for (int i = 1; i < n; i++) {
        if (ind_max == i) {
            for (int j = i; j < n; j++) {
                new_ind_inters.push_back(indexes_inters[j]);
            }
            for (int j = 0; j < i; j++) {
                new_ind_inters.push_back(indexes_inters[j]);
            }
        }
    }
//    cout << "!" << endl;
    time_inters = time_inters_source;
    indexes_inters = new_ind_inters;
    cur_t = time_inters[indexes_inters[0]];
//    cout << indexes_inters[0] << " ind_inters ";
    for (int i = 1; i < n; i++) {
        int t_oper = 0;
        if (time_inters[indexes_inters[i]] >= time_inters[indexes_inters[i - 1]]) {
            t_oper = (time_inters[indexes_inters[i]] - time_inters[indexes_inters[i - 1]]);
        } else {
            t_oper = (time_inters[indexes_inters[i]] - time_inters[indexes_inters[i - 1]] + 2 * m - 2);
        }
        t_oper /= 2;
//        cout << indexes_inters[i] << " ";
        m -= t_oper;
        cur_t += t_oper;
        if (t_oper == 0) {
            continue;
        }
        print_ans.push_back({cur_t, m});
    }
    /*
    cout << endl;
    cout << "time_inters = " << endl;
    for (int i = 0; i < n; i++) {
        cout << time_inters[indexes_inters[i]] << " ";
    }
    cout << endl;
    */
    cout << print_ans.size() << endl;
    for (auto p : print_ans) {
        cout << p.first << " " << p.second << endl;
    }
    return 0;
}
