#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    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;
    vector<int> pos(n);
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            pos[i] = a[i];
        }else{
            pos[i] = 2 * m - a[i] - 2;
        }
    }

    for(int i = 0; i < n; i++){
        if(pos[i] % 2 != pos[0] % 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    if(t == 1){
        return 0;
    }
    vector<int> usl(n);
    for(int i = 1; i < n; i++){
        if(pos[i] == pos[i - 1]){
            usl[i] = 1;
        }
    }
    vector<int> nwpos;
    for(int i = 0; i < n; i++){
        if(usl[i] == 0){
            nwpos.push_back(pos[i]);
        }
    }
    pos = nwpos;
    n = pos.size();
    sort(pos.begin(), pos.end());
    int mx = 0, ind = 0;
    for(int i = 0; i < n - 1; i++){
        if((pos[i + 1] - pos[i]) / 2 >= mx){
            ind = i;
            mx = (pos[i + 1] - pos[i]) / 2;
        }
    }
    if((2 * m - 2 + pos[0] - pos[n - 1]) / 2 >= mx){
        ind = n - 1;
        mx = (2 * m - 2 + pos[0] - pos[n - 1]) / 2;
    }
    cout << mx + 1 << endl;
    if(t == 2){
        return 0;
    }
    vector<pair<int, int>> ans;
    int st = (ind + 1) % n;
    int nt = 0;
    while(st != ind){
        int dst;
        if(st == n - 1){
            dst = 2 * m - 2 + pos[0] - pos[n - 1];
        }else{
            dst = pos[st + 1] - pos[st];
        }
        if(dst == 0){
            st = (st + 1) % n;
            continue;
        }
        int newm = m - dst / 2;
        int tleft = newm - 1 - pos[st];
        if(tleft < 0){
            tleft += 2 * m - 2;
        }
        ans.push_back({nt + tleft, newm});
        nt += tleft;
        for(int i = 0; i < n; i++){
            pos[i] += tleft;
            pos[i] %= (2 * m - 2);
            if(pos[i] >= m){
                pos[i] -= dst;
            }
        }
        m = newm;
        st = (st + 1) % n;
    }
    cout << ans.size() << endl;
    for(auto u: ans){
        cout << u.first << " " << u.second << endl;
    }
}
