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

#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
#pragma GCC target("avx", "avx2")

using ll = long long;
using lll = __int128;
using dd = long double;
using para = pair <ll, ll>;
using parad = pair <dd, dd>;
using vll = vector <ll>;
struct f {
    ll i = -1, j = -1, nap = -1;
};
void solvetask() {
    ll T;
    cin >> T;
    ll n, m;
    cin >> n >> m;
    set <ll> ost;
    vector <f> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i].j;
        a[i].j--;
        a[i].i = i;
        ost.insert(a[i].j % 2);
    }
    string s;
    cin >> s;
    for (ll i = 0; i < n; ++i) {
        if (s[i] == 'L') {
            a[i].nap = 0;
        } else {
            a[i].nap = 1;
        }
    }
    if (ost.size() == 1) {
        cout << "Yes\n";
    } else {
        cout << "No";
        return;
    }
    if (T == 1) return;
    if (n == 2 && a[0].j == 0 && a[1].j == m - 1) {
        cout << (m - 1) / 2 + 1 << "\n";
        if (T == 2) return;
        cout << "1\n";
        cout << (m - 1) / 2 << ' ' << (m - 1) / 2 + 1 << "\n";
        return;
    }
    vector <para> ans;
    ll t = 0;
    m--;
    while (true) {
        bool fl1 = true;
        for (ll i = 0; i < n; ++i) {
            if (a[i].nap == 0) {
                fl1 = false;
                break;
            }
        }
        if (fl1) {
            t++;
            for (ll i = 0; i < n; ++i) {
                if (a[i].nap == 0) {
                    if (a[i].j == 1) {
                        a[i].j = 0;
                        a[i].nap = 1;
                    } else {
                        a[i].j--;
                    }
                } else {
                    if (a[i].j == m - 1) {
                        a[i].j = m;
                        a[i].nap = 0;
                    } else {
                        a[i].j++;
                    }
                }
            }
            continue;
        }
        ll maxj = 0;
        for (ll i = 0; i < n; ++i) {
            maxj = max(maxj, a[i].j);
        }
        if (maxj != m) {
            ans.push_back({t, maxj + 1});
            m = maxj;
        }
        bool fl = true;
        for (ll i = 0; i < n; ++i) {
            if (a[i].j != m) {
                fl = false;
                break;
            }
        }
        if (fl) break;
        for (ll i = 0; i < n; ++i) {
            if (a[i].nap == 0) {
                if (a[i].j == 1) {
                    a[i].j = 0;
                    a[i].nap = 1;
                } else {
                    a[i].j--;
                }
            } else {
                if (a[i].j == m - 1) {
                    a[i].j = m;
                    a[i].nap = 0;
                } else {
                    a[i].j++;
                }
            }
        }
        t++;
    }
    cout << m + 1 << "\n";
    if (T == 2) return;
    cout << ans.size() << "\n";
    for (auto& c : ans) {
        cout << c.first << ' ' << c.second << "\n";
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll tests = 1;
    //cin >> tests;
    while (tests--) {
        solvetask();
    }
    return 0;
}