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

const int MAXN = 2e5 + 10;
long long a[MAXN], b[MAXN];

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    
    long long n, m;
    cin >> n >> m;
    
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    for (int i = 1; i <= n; i++) {
        char ds;
        cin >> ds;

        b[i] = ds == 'R';
    }

    for (int i = 1; i <= n; i++) {
        if (a[i] % 2 != a[1] % 2) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    if (t == 1) return 0;
    
    long long modulo = 2 * (m - 1);

    for (int i = 1; i <= n; i++) {
        a[i]--;
        if (b[i] == 0) a[i] = modulo - a[i];
    }

    sort(a + 1, a + n + 1);

    long long ans = 0, idx;

    for (int i = 1; i <= n; i++) {
        long long x = a[i], y = a[i % n + 1];
        if (i == n) y += modulo;

        if (ans < 1 + (y - x) / 2) {
            ans = 1 + (y - x) / 2;
            idx = i;
        }

        ans = max(ans, 1 + (y - x) / 2);
    }

    cout << ans << '\n';
    if (t == 2) return 0;

    long long initial_time = (m - 1 - a[idx] + modulo) % modulo;
    long long len = m;

    int cnt = 0;

    for (int i = 1; i <= n; i++) {
        if (i == idx) continue;
        if (a[i] != a[i % n + 1]) cnt++;
    }

    cout << cnt << '\n';
    
    int i = idx;

    int gt = 0;

    while (1) {
        int j = i - 1;
        if (j == 0) j = n;
        if (j == idx) break;

        long long diff = a[i] - a[j];
        if (diff < 0) diff += modulo;
        
        initial_time += diff / 2;
        len -= diff / 2;
        
        if (a[i] == a[j]) {
            i = j;
            continue;
        }

        i = j;
        cout << initial_time << ' ' << len << endl;
    }

    return 0;

}