#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>
#define ff first
#define ss second
#define ld long double
#define pb push_back
#define ins insert
#define str string
#define int ll

mt19937 rnd(1488);

int T, n, m;
vector<int> cl;
vector<int> cr;
str s;

void solve(){
    cin >> T;
    cin >> n >> m;
    vector<int> c(n);
    for (int i = 0; i < n; i++){
        cin >> c[i];
    }
    cin >> s;
    for (int i = 0; i < n; i++){
        if (s[i] == 'L'){
            cl.pb(c[i]);
        }
        else{
            cr.pb(c[i]);
        }
    }
    if (cl.size()){
        for (auto i:cl){
            if (i % 2 != cl[0] % 2){
                cout << "No\n";
                return;
            }
        }
        if (cr.size()){
            for (auto i:cr){
                if (i % 2 != cl[0] % 2){
                    cout << "No\n";
                    return;
                }
            }
        }
    }
    if (cr.size()){
        for (auto i:cr){
            if (i % 2 != cr[0] % 2){
                cout << "No\n";
                return;
            }
        }
    }
    cout << "Yes\n";
    if (T == 2){
        vector<int> c1(m);
        vector<int> c2(m);
        for (auto i:cl){
            c1[i - 1]++;
        }
        for (auto i:cr){
            c2[i - 1]++;
        }
        set<pair<vector<int>, vector<int>>> st;
        st.ins({c1, c2});
        deque<pair<vector<int>, vector<int>>> q = {{c1, c2}};
        int ans = 0;
        int cnt = 0;
        while (q.size()){
            auto [x, y] = q[0];
            q.pop_front();
            if (x.size() < ans) continue;
            int lst1 = 0;
            for (int i = 0; i < x.size(); i++){
                if (x[i] || y[i]){
                    lst1 = i;
                }
            }
            if (x[lst1] == n || y[lst1] == n){
                ans = max(ans, (int)x.size());
                continue;
            }
            vector<int> x2;
            vector<int> y2;
            for (int i = 0; i < x.size(); i++){
                x2.pb(x[i]);
                y2.pb(y[i]);
                if (i >= lst1){
                    int pp = y2.back();
                    x2.back() += pp;
                    y2.back() = 0;
                    if (st.find({x2, y2}) == st.end()){
                        q.pb({x2, y2});
                        st.ins({x2, y2});
                    }
                    x2.back() -= pp;
                    y2.back() += pp;
                }
            }
            x2.assign((int)x.size(), 0);
            y2.assign((int)x.size(), 0);
            for (int i = 2; i < x.size(); i++){
                x2[i - 1] = x[i];
            }
            y2[0] = x[1];
            for (int i = (int)x.size() - 3; i >= 0; i--){
                y2[i] = y[i + 1];
            }
            x2[(int)x.size() - 1] = y[(int)x.size() - 2];
            if (st.find({x2, y2}) == st.end()){
                st.ins({x2, y2});
                q.pb({x2, y2});
            }
        }
        if (ans == 0){
            assert(0);
        }
        cout << ans << "\n";
    }
}

int32_t main(){
    cin.tie(0)->ios_base::sync_with_stdio(0);
    #ifdef podureman
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif // podureman
    int _ = 1;
    //cin >> _;
    while (_--){
        solve();
    }
}
