#include <bits/stdc++.h>

#ifndef LOCAL
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#endif

using namespace std;
using ll = int64_t;
const ll inf = 1e18;
void solve();

template<typename T, typename T1> T remax(T& x, T1 y) { if (x < y) x = y; return x; }
template<typename T, typename T1> T remin(T& x, T1 y) { if (y < x) x = y; return x; }

int main() {
#ifdef BLOCKS
    freopen("input.txt", "r", stdin);
#endif // BLOCKS
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) solve();
}
#define int int64_t

void solve() {
    int t; cin >> t;
    int n, m; cin >> n >> m;
    vector<int> a(n);
    for (auto& x : a) cin >> x;
    string s; cin >> s;
    bool ok = 1;
    for (int i = 1; i < n; ++i) ok &= ~(a[i] - a[0]) & 1;
//    cout << (ok ? "Yes\n" : "No\n");
    if (!ok) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
    if (t == 1) return;
    bool al = 1;
    for (int i = 1; i < n; ++i) al &= a[0] == a[i] && s[0] == s[i];
    if (al) {
        cout << m << '\n';
        if (t == 2) return;
        cout << 0;
        return;
    }
    if (n == 2) {
        int ans = -1;
        pair<int, int> r;
        if (a[0] > a[1]) {
            swap(a[0], a[1]);
            swap(s[0], s[1]);
        }
        int point, time = 0;
        if (s == "LR") {
            int t1 = a[0] - 1, t2 = m - a[1];
            time = min(t1, t2);
            if (t1 == t2) a[0] = 1, a[1] = m, s = "RL";
            else if (t1 < t2) a[0] = 1, a[1] += time, s = "RR";
            else a[0] -= time, a[1] = m, s = "LL";
        }
        if (s == "RL") point = (a[0] + a[1]) / 2, time += (a[1] - a[0]) / 2;
        else if (s == "LL") point = (a[0] + a[1]) / 2 - (a[0] - 1), time += a[0] - 1 + (a[1] - a[0]) / 2;
        else if (s == "RR") point = (a[0] + a[1]) / 2 + (m - a[1]), time += m - a[1] + (a[1] - a[0]) / 2;

        if (point >= m + 1 - point) ans = point, r = {time, point};
        else point = m + 1 - point, ans = point, r = {time + m - 1, point};

        cout << ans << '\n';
        if (t == 2) return;
        cout << "1\n";
        cout << r.first << ' ' << r.second;
        return;
    }
    if (t == 2 && std::count(s.begin(), s.end(), 'R') == n) {
        cout << m - 1;
        return;
    } else exit(-1);
    int ans = -1;
    vector<pair<int, int>> r;
    vector<int> tr(m + 1, -1);
    vector<pair<vector<int>, string>> rem(m + 1);
    for (int i = 0; i < m * 1000; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (tr[j] > -1) continue;
            bool cur = 1;
            for (int p = 0; p < n; ++p) cur &= a[p] <= j;
            if (!cur) continue;
            tr[j] = i;
            rem[j] = {a, s};
        }
        bool can = 1;
        for (int j = 1; j < n; ++j) can &= a[0] == a[j];
        if (can && ans < a[0]) {
            ans = a[1];
            r = {{i, a[1]}};
        }
        for (int j = 0; j < n; ++j) {
            if (s[j] == 'R') a[j]++;
            else a[j]--;
            assert(a[j] >= 1 && a[j] <= m);
            if (a[j] == m) s[j] = 'L';
            if (a[j] == 1) s[j] = 'R';
        }
    }
    for (int z = 2; z <= m; ++z) {
        if (tr[z] == -1) continue;
        a = rem[z].first, s = rem[z].second;
        for (int i = tr[z]; i < m * 1000; ++i) {
            bool can = 1;
            for (int j = 1; j < n; ++j) can &= a[0] == a[j];
            if (can && ans < a[0]) {
                ans = a[1];
                r = {{tr[z], z}, {i, a[1]}};
            }
            for (int j = 0; j < n; ++j) {
                if (a[j] == z) s[j] = 'L';
                if (a[j] == 1) s[j] = 'R';

                if (s[j] == 'R') a[j]++;
                else a[j]--;
                assert(a[j] >= 1 && a[j] <= z);
            }
        }
    }
    cout << ans << '\n';
    if (t == 2) return;
    cout << r.size() << '\n';
    for (auto& x : r) cout << x.first << ' ' << x.second << '\n';
}
