#include "bits/stdc++.h"

#pragma GCC optimize("03,unroll-loops")

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define len(x) ((int)x.size())

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

void solve() {
    int T;
    cin >> T;

    int n, m;
    cin >> n >> m;
    vector<array<int, 2>> a(n);
    vector<int> w;
    for (int i = 0; i < n; ++i) {
        cin >> a[i][0];
        --a[i][0];
        w.push_back(a[i][0]);
    }
    for (int i = 0; i < n; ++i) {
        char c;
        cin >> c;
        if (c == 'R') {
            a[i][1] = 1;
        } else {
            a[i][1] = -1;
        }
    }
    sort(all(w));
    w.resize(unique(all(w)) - w.begin());
    if (len(w) == m) {
        cout << "No";
        return;
    } else if (T) {
        cout << "Yes";
        return;
    }
    sort(all(a));
    vector<array<ll, 2>> ans;
    ll time = 0;
    for (int j = m - 1; j >= 0; --j) {
        // cout << j << endl;
        for (int t = 0; t < 2 * m; ++t, ++time) {
            int fl = 1;
            for (int i = 1; i < n; ++i) {
                if (a[i] != a[0]) {
                    fl = 0;
                    break;
                }
            }
            if (fl) {
                cout << "Yes\n";
                if (T > 1) {
                    cout << j + 1 << '\n';
                    if (T > 2) {
                        cout << len(ans) << '\n';
                        for (auto [tm, x] : ans) cout << tm << ' ' << x << '\n';
                    }
                }
                return;
            }
            if (j == 0) break;
            for (int i = 0; i < n; ++i) {
                if (a[i][0] == 0 && a[i][1] < 0) {
                    a[i][1] *= -1;
                } else if (a[i][0] == j && a[i][1] > 0) {
                    a[i][1] *= -1;
                }
                a[i][0] += a[i][1];
            }
        }
        int fl = 1;
        for (int t = 0; t < 2 * m; ++t, ++time) {
            int f = 1;
            for (int i = 0; i < n; ++i) {
                if (a[i][0] == j && a[i][1] == 1) {
                    a[i][1] = -1;
                }
            }
            for (int i = 0; i < n; ++i) {
                if (a[i][0] >= j) {
                    f = 0;
                    break;
                }
            }
            if (f) {
                ans.push_back({time, j});
                fl = 0;
                break;
            }
            for (int i = 0; i < n; ++i) {
                if (a[i][0] == 0 && a[i][1] < 0) {
                    a[i][1] *= -1;
                } else if (a[i][0] == j && a[i][1] > 0) {
                    a[i][1] *= -1;
                }
                a[i][0] += a[i][1];
            }
        }
        if (fl) {
            cout << "No";
            return;
        }
        for (int i = 0; i < n; ++i) {
            if (a[i][0] == j && a[i][1] == 1) {
                a[i][1] = -1;
            }
        }
    }
    cout << "No";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _ = 1;
    // cin >> _;
    while (_--) {
        solve();
        cout << '\n';
    }
}
