#include "bits/stdc++.h"

#ifdef LOCAL
#include "debug.h"
#else
#define debug(x...) 228
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define fi first
#define se second

const int inf = int(1e9) + 1;
const ll infll = ll(1e18) + 1;
const int mod = int(1e9) + 7;
mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template<typename T1, typename T2>
bool chmin(T1 &a, T2 b) {
    if (a > b) return a = b, true;
    return false;
}
template<typename T1, typename T2>
bool chmax(T1 &a, T2 b) {
    if (a < b) return a = b, true;
    return false;
}

bool eq(vector<int> a) {
    return min_element(a.begin(), a.end()) == max_element(a.begin(), a.end());
}

bool eq(string s) {
    return min_element(s.begin(), s.end()) == max_element(s.begin(), s.end());
}

struct Buble {
    vector<int> a;
    string s;
    int m{};

    void next() {
        for (int i = 0; i < a.size(); i++) {
            if (s[i] == 'L') {
                a[i]--;
            } else {
                a[i]++;
            }
            if (a[i] == -1) {
                s[i] = 'R';
                a[i] = 1;
            } else if (a[i] == m) {
                s[i] = 'L';
                a[i] = m - 2;
            }
        }
    }

    bool ok() {
        return m == 1 || (eq(a) && eq(s));
    }
};

bool operator < (Buble left, Buble right) {
    return tie(left.a, left.s, left.m) < tie(right.a, right.s, right.m);
}

void solve_case() {
    int MODE; cin >> MODE;
    int n, m; cin >> n >> m;
    vector<int> a(n);
    set<int> par;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        par.insert(a[i] % 2);
    }
    string s; cin >> s;
    if (par.size() == 2) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
        map<Buble, int> ans;
        set<Buble> us;
        auto svo = [&](auto &&self, Buble x) -> int {
            if (ans.find(x) != ans.end()) return ans[x];
            if (x.ok()) return ans[x] = x.m;
            if (us.find(x) != us.end()) return 0;
            us.insert(x);
            Buble y = x;
            Buble was = x;
            int z = 0;
            if (*max_element(x.a.begin(), x.a.end()) < x.m - 1) {
                y.m--;
                z = self(self, y);
            }
            x.next();
            z = max(z, self(self, x));
            return ans[was] = z;
        };
        Buble me;
        me.a = a;
        me.s = s;
        me.m = m;
        cout << svo(svo, me) << "\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int T = 1;
    while (T--) {
        solve_case();
    }
#ifdef LOCAL
    fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
#endif
}
