#include <bits/stdc++.h>

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

#ifdef LOCAL
#define __lg(x) log2(x)
#endif

using ld = long double;
using ll = long long;

using namespace std;

using TT = pair<pair<vector<int>, vector<int>>, int>;

void solve() {
    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;

    for (int i = 0; i < n; ++i) {
        if (a[i] % 2 != a[0] % 2) {
            cout << "NO\n";
            return;
        }
    }

    vector<int> mv(n);
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'L') mv[i] = -1;
        else mv[i] = 1;
    }

    map<TT, int> dist;
    TT z = {{a, mv}, m};
    dist[z] = 0;
    queue<TT> q;
    q.emplace(z);

    auto check = [](vector<int> a, vector<int> mv, int m) {
        if (m == 1) return true;
        for (int i = 0; i < len(a); ++i) {
            if (a[i] == 1 && mv[i] == -1) mv[i] = 1;
            if (a[i] == m && mv[i] == 1) mv[i] = -1;
            if (a[i] != a[0] || mv[i] != mv[0]) return false;
        }
        return true;
    };

    auto make_move = [](vector<int> &a, vector<int> &mv, int m) {
        int n = len(a);
        for (int i = 0; i < n; ++i) {
            if (a[i] == 1 && mv[i] == -1) mv[i] = 1;
            else if (a[i] == m && mv[i] == 1) mv[i] = -1;
            a[i] += mv[i];
            if (a[i] > m) exit(1);
        }
    };

    int it = 0;
    int ans = 0;
    while (len(q)) {
        ++it;
        if (it % 1000 == 0) cerr << len(dist) << endl;
        auto zz = q.front();
        int cur_d = dist[zz];
        q.pop();
        auto aa = zz.first.first;
        auto mvv = zz.first.second;
        int M = zz.second;
        if (M < ans) continue;
        if (check(aa, mvv, M)) {
            ans = max(ans, M);
        }
        if (M == 1) continue;

        int mx = *max_element(all(aa));
        for (int j = mx; j < M; ++j) {
            TT zzz = {{aa, mvv}, j};
            if (!dist.count(zzz)) {
                dist[zzz] = cur_d + 1;
                q.emplace(zzz);
            }
        }

        make_move(aa, mvv, M);
        TT zzz = {{aa, mvv}, M};
        if (!dist.count(zzz)) {
            dist[zzz] = cur_d + 1;
            q.emplace(zzz);
        }
    }
    if (ans == 0) exit(1);
    cout << "YES\n";
    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) solve();
}