#define _GLIBCXX_DEBUG

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

#define int long

const int MOD = 998244353, MAXN = 431, INF = 1e18;

pair<int, vector<pair<int, int>>> solve(vector<int> pos, vector<int> tp, int m){
    //cout << "SOLVE\n";
    int n = pos.size();
    vector<pair<int, int>> ord;
    if(m == 1) return {1, ord};
    bool OK = 1;
    for(int i = 0; i < n; i++){
        if(pos[i] == 1) tp[i] = 1;
        if(pos[i] == m) tp[i] = -1;
    }
    for(int i = 0; i < n; i++){
        if(pos[i] != pos[0] || tp[i] != tp[0]) OK = 0;
    }
    if(OK) return {m, ord};
    int res = -1;
    if(0);
    else{
        for(int tm = 0; tm <= m * 2; tm++){
            bool can = 0;
            int rr = -1, cnt = 0;
            bool diff = 0;
            int mn_tp = -1;
            //cout << pos[0] << " " << pos[1] << "\n";
            for(int i = 0; i < n; i++){
                if(rr < pos[i]){
                    rr = pos[i];
                    cnt = 0;
                    mn_tp = tp[i];
                }
                if(rr == pos[i]){
                    cnt++;
                    if(mn_tp != tp[i]) diff = 1;
                }
            }
            if(rr < m && cnt > 1){
                pair<int, vector<pair<int, int>>> now = solve(pos, tp, rr);
                if(now.first > res){
                    res = now.first;
                    ord = now.second;
                    for(int i = 0; i < ord.size(); i++) ord[i].first += tm;
                    ord.push_back({tm, rr});
                }
            }
            for(int i = 0; i < n; i++){
                pos[i] += tp[i];
                if(pos[i] == 1) tp[i] = 1;
                if(pos[i] == m) tp[i] = -1;
            }
        }
    }
    return {res, ord};
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int T;
    cin >> T;
    int n, m;
    cin >> n >> m;
    vector<int> pos(n);
    vector<int> tp(n);
    for(int i = 0; i < n; i++) cin >> pos[i];
    string s;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') tp[i] = 1;
        else tp[i] = -1;
    }
    bool OK = 1;
    for(int i = 1; i < n; i++){
        if(pos[i] % 2 != pos[0] % 2) OK = 0;
    }
    if(!OK){
        cout << "No";
        return 0;
    }
    
    cout << "Yes\n";
    int res = -1;
    vector<pair<int, int>> ord;
    if(T > 1){
        pair<int, vector<pair<int, int>>> now = solve(pos, tp, m);
        res = now.first;
        ord = now.second;
        if(T >= 2){
            cout << res << "\n";
        }
        if(T >= 3){
            cout << ord.size() << "\n";
            //cout << (pos[0] + pos[1]) / 2 - 1 << " " << (pos[0] + pos[1]) / 2 << "\n";
            for(auto [x, y] : ord) cout << x << " " << y << "\n";
        }
    }
}