#include <bits/stdc++.h>

using namespace std;

#ifndef lisie_bimbi
#define endl '\n'
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,bmi2,fma")
#endif

using ll = long long;

#define int long long

int mod;

void solve(){
    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] = 2 * m - 2 - a[i];
        }
    }
    sort(a.begin(), a.end());
    // for(auto i : a){
    //     cout << i << ' ';
    // }
    // cout << endl;
    int mx = 0;
    for(int i = 0; i < n; i++){
        if(i != n - 1){
            if(abs(a[i + 1] - a[i]) % 2 != 0){
                cout << "No\n";
                return;
            }else{
                mx = max(mx, a[i + 1] - a[i]);
            }
        }else{
            if(abs(a[0] - a[i]) % 2 != 0){
                cout << "No\n";
                return;
            }else{
                mx = max(mx, a[0] - a[i] + 2 * m - 2);
            }
        }
    }
    cout << "Yes\n";
    if(t >= 2){
        cout << (mx + 2) / 2 << endl;
    }
    int start = -1;
    for(int i = 0; i < n; i++){
        if(i != n - 1){
            if(abs(a[i + 1] - a[i]) == mx){
                start = i + 1;
            }
        }else{
            if((a[0] - a[i] + 2 * m - 2) == mx){
                start = 0;
            }
        }
    }
    vector<int> b;
    for(int i = start; i < n; i++){
        b.push_back(a[i]);
    }
    for(int i = 0; i < start; i++){
        b.push_back(a[i] + 2 * m - 2);
    }
    vector<int> mid;
    vector<int> z;
    for(int i = 0; i + 1 < b.size(); i++){
        mid.push_back((b[i] + b[i + 1]) / 2);
        z.push_back((b[i + 1] - b[i]) / 2);
    }
    vector<pair<int, int>> ans;
    ans.push_back({(2 * m - 2) * 10 + m - 1 - mid.back(), z.back()});
    ans[0].first %= (2 * m - 2);
    for(int i = (int)mid.size() - 2; i >= 0; i--){
        auto [x, y] = ans.back();
        ans.emplace_back(x + z.back(), z.back());
    }
    cout << ans.size() << endl;
    for(auto [i, j] : ans){
        cout << i << ' ' << m - j << endl;
        m -= j;
    }
}

signed main(){
#ifdef lisie_bimbi
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);   
#else
    cin.tie(nullptr)->sync_with_stdio(false);
#endif         
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}