#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


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];
        }
    }
    auto a1 = a;
    int m1 = m;
    sort(a.begin(), a.end());
    int sz = unique(a.begin(), a.end()) - a.begin();
    a.resize(sz);
    n = sz;
    if(n == 1){
        cout << "Yes\n";
        if(t >= 2){
            cout << m << endl;
        }
        if(t >= 3){
            cout << "0\n";
        }
        return;
    }
    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;
    }
    if(t != 3){
        return;
    }
    int start = -1;
    for(int i = 0; i < n; i++){
        if(i != n - 1){
            if(a[i + 1] - a[i] == mx){
                start = i + 1;
                break;
            }
        }else{
            if((a[0] - a[i] + 2 * m - 2) == mx){
                start = 0;
                break;
            }
        }
    }
    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);
    }
    // for(auto i : b){
    //     cout << i << ' ';
    // }
    // cout << endl;
    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[i], z[i]);
    }
    // for(auto i : ans){
    //     cout << i.first << ' ' << i.second << endl;
    // }
    // for(auto i : b){
    //     cout << i << ' ';
    // }
    // cout << endl;
    // return;
    cout << ans.size() << endl;
    for(auto &[i, j] : ans){
        j = m - j;
        m = j;
        cout << i << ' ' << j << endl;
    }
    return;
    cout << endl;
    int was = 0;
    for(auto i : a1){
        cout << i << ' ';
    }
    cout << endl;
    for(auto [tt, x] : ans){
        // cout << "aaaaa " << tt << ' ' << x << endl;
        tt -= was;
        cout << "aaaaa " << tt << ' ' << x << endl;
        int k = m1 - x;
        for(auto &i : a1){
            i += tt;
            i %= m1 * 2 - 2;
        }
        for(auto i : a1){
            cout << i << ' ';
        }
        cout << endl;
        for(auto i : a1){
            if(i >= m1){
                i = 2 * m1 - 2 - i;
            }
            if(i >= x){
                assert(0);
            }
        }
        for(auto &i : a1){
            if(i >= m1){
                i -= 2 * k;
            }
        }
        for(auto i : a1){
            cout << i << ' ';
        }
        cout << endl;
        m1 = x;
        was += tt;
    }
}

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();
    }
    return 0;
}