//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <experimental/random>

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

const ll INF = 3e18, MOD = 998244353;

void solve();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int q = 1;
    // cin >> q;
    while (q--) {
        solve();
    }
}

void solve() {
    int T, n, m;
    cin >> T >> n >> m;
    bool f1 = false, f2 = false;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        a[i] = x - 1;
        if (x % 2 == 0) {
            f1 = true;
        } else {
            f2 = true;
        }
    }
    string s;
    cin >> s;
    if (f1 && f2) {
        cout << "No";
        return;
    } else {
        cout << "Yes\n";
    }

    if (T == 1) {
        return;
    }

    int t = 0;
    vector<pair<int, int>> ans;
    for (int _ = 0; _ < n; _++) {
        vector<int> f1(m), f2(m);
        bool flag = false;
        for (int i = 0; i < n; i++) {
            if (s[i] == 'L') {
                f1[a[i]]++;
            } else {
                f2[a[i]]++;
            }
            if (f1[a[i]] == n || f2[a[i]] == n) {
                flag = true;
            }
        }
        
        if (flag) {
            break;
        }

        vector<pair<int, int>> moments;
        vector<int> ac = a;
        string sc = s;
        
        for (int j = 0; j < 2 * m; j++) {
            f1.assign(m, 0), f2.assign(m, 0);
            for (int i = 0; i < n; i++) {
                if (sc[i] == 'L') {
                    f1[ac[i]]++;
                } else {
                    f2[ac[i]]++;
                }
            }
            for (int x = m - 1; x >= 0; x--) {
                if (!f1[x] && !f2[x]) {
                    continue;
                }
                if (f1[x] && f2[x]) {
                    moments.emplace_back(x + 1, j);
                }
                break;
            }

            for (int i = 0; i < n; i++) {
                if (sc[i] == 'L') {
                    ac[i]--;
                } else {
                    ac[i]++;
                }
                if (ac[i] == 0) {
                    sc[i] = 'R';
                }
                if (ac[i] == m - 1) {
                    sc[i] = 'L';
                }
            }
        }

        sort(moments.rbegin(), moments.rend());
        auto [nxt, tm] = moments.front();
        for (int j = 0; j < tm; j++) {
            for (int i = 0; i < n; i++) {
                if (s[i] == 'L') {
                    a[i]--;
                } else {
                    a[i]++;
                }
                if (a[i] == 0) {
                    s[i] = 'R';
                }
                if (a[i] == m - 1) {
                    s[i] = 'L';
                }
            }
        }
        if (nxt != m) {
            m = nxt;
            ans.emplace_back(nxt, tm + t);
        }
        for (int i = 0; i < n; i++) {
            if (a[i] == 0) {
                s[i] = 'R';
            }
            if (a[i] == m - 1) {
                s[i] = 'L';
            }
        }
        t += tm;
    }
    cout << m << '\n';
    if (T == 2) {
        return;
    }

    cout << ans.size() << '\n';
    for (auto [x, y] : ans) {
        cout << y << ' ' << x << '\n';
    }
}
