// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin >> T;
    int n, m;
    cin >> n >> m;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    string s;
    cin >> s;
    bool isAns = true;
    for (int i = 1; i < n && isAns; ++i) {
        if (s[i - 1] == s[i]) {
            isAns = abs(a[i - 1] - a[i]) % 2 == 0;
        } else {
            isAns = (a[i - 1] + a[i]) % 2 == 0;
        }
    }
    if (isAns) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    if (T == 1 || !isAns) {
        return 0;
    }
    if (n == 2 && a[0] == 1 && a[1] == m) {
        cout << "1\n";
        if (T == 2) return 0;
        cout << m / 2 << " " << (m + 1) / 2 << "\n";
        return 0;
    }
    int x = m;
    vector <pair <ll, int>> ans;
    ll tmr = 0;
    int cur = 0;
    while (true) {
        bool good = true;
        cur++;
        for (int i = 1; i < n && good; ++i) {
            good = a[i - 1] == a[i] && s[i - 1] == s[i];
        }
        if (good) break;
        int dt = 2 * x;
        for (int i = 0; i < n; ++i) {
            if (a[i] == x) {
                dt = 0;
                break;
            }
            if (s[i] == 'R') {
                dt = min(dt, x - a[i]);
            } else {
                dt = min(dt, 2 * (a[i] - 1) + x - a[i]);
            }
        }
        dt++;
        for (int i = 0; i < n; ++i) {
            if (s[i] == 'R') {
                a[i] += dt;
                if (a[i] >= x) {
                    a[i] = x - (a[i] - x);
                    s[i] = 'L';
                }
            } else {
                a[i] -= dt;
                if (a[i] <= 1) {
                    a[i] = 1 + (1 - a[i]);
                    s[i] = 'R';
                }
            }
            if (s[i] == 'R') {
                if (a[i] >= x) {
                    a[i] = x - (a[i] - x);
                    s[i] = 'L';
                }
            } else {
                if (a[i] <= 1) {
                    a[i] = 1 + (1 - a[i]);
                    s[i] = 'R';
                }
            }
        }
        tmr += dt;
        ans.emplace_back(tmr, --x);
        for (int i = 0; i < n; ++i) {
            if (a[i] == x) {
                s[i] = 'L';
            }
        }
    }
    cout << x << "\n";
    if (T == 2) return 0;
    cout << ans.size() << "\n";
    for (const auto & [i, j] : ans) {
        cout << i << " " << j << "\n";
    }
    return 0;
}