#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

int a[N];

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

    int T; cin >> T;

    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> b;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        b.push_back({a[i], i});
    }

    sort(b.begin(), b.end());

    bool subR = 1, subL = 1;
    string s, t; cin >> t;

    s = t;
    for (int i = 0; i < n; ++i) {
        s[i] = t[b[i].second - 1];
    }

    for (int i = 0; i < n; ++i) {
        subR = (s[i] == 'L' ? 0 : subR);
        subL = (s[i] == 'R' ? 0 : subL);
    }

    sort(a + 1, a + n + 1);

    for (int i = 2; i <= n; ++i) {
        if ((a[i] - a[i - 1]) & 1) {
            cout << "No\n";
            return 0;
        }
    }
    
    cout << "Yes\n";
    
    if (subR) {
        bool diff = 0;
        for (int i = 2; i <= n; ++i) {
            if (a[i] != a[i - 1]) diff = 1;
        }

        if (!diff) {
            if (T >= 2) {
                cout << m << "\n";
            } if (T == 3) {
                cout << 0 << "\n";
            }

            return 0;
        }

        int t = m - a[n];

        int ptr = n;
        while (a[ptr] + t == m) {
            --ptr;
        }

        int mn = m;
        vector<pair<int, int>> move;
        for (int i = ptr; i >= 1; --i) {
            while (a[ptr] == a[i]) {
                --ptr;
            }

            int l = i, r = ptr + 1;
            
            t += (a[l + 1] - a[l]) / 2;
            move.push_back({t, a[l] + t});
            mn = min(mn, move.back().second);

            i = r;
        }

        if (T >= 2) {
            cout << mn << "\n";
        }

        if (T == 3) {
            cout << move.size() << "\n";
            for (auto& [a, b]: move) {
                cout << a << " " << b << "\n";
            }
        }

        return 0;
    }

    if (n == 2 && a[1] == 1 && a[2] == m) {
        if (T >= 2) {
            cout << (m + 1) / 2 << "\n";
        }

        if (T == 3) {
            cout << 1 << "\n";
            cout << (m - 1) / 2 << " " << (m + 1) / 2 << "\n";
        }

        return 0;
    }
    if (n == 2) {
        vector<pair<int, int>> isec;

        if (a[1] == a[2]) {
            if (s[0] == s[1]) {
                if (T >= 2) {
                    cout << m << "\n";
                }
                if (T == 3) {
                    cout << 0 << "\n";
                }

                return 0;
            } else {
                isec.push_back({a[1], 0});
            }
        }
        
        int it = 20, timer = 0;
        while (--it) {
            int diff = m;

            if (s[0] == 'L') diff = min(diff, a[1] - 1);
            else diff = min(diff, m - a[1]);
            
            if (s[1] == 'L') diff = min(diff, a[2] - 1);
            else diff = min(diff, m - a[2]);
            
            if (a[1] < a[2] && s[0] == 'R' && s[1] == 'L') {
                diff = min(diff, (a[2] - a[1]) / 2);
            }

            if (a[2] < a[1] && s[1] == 'R' && s[0] == 'L') {
                diff = min(diff, (a[1] - a[2]) / 2);
            }

            timer += diff;

            if (s[0] == 'L') a[1] -= diff;
            else a[1] += diff;

            if (s[1] == 'L') a[2] -= diff;
            else a[2] += diff;
            
            if (a[1] == m) s[0] = 'L';
            if (a[1] == 1) s[0] = 'R';

            if (a[2] == m) s[1] = 'L';
            if (a[2] == 1) s[1] = 'R';

            if (a[1] == a[2]) {
                isec.push_back({a[1], timer});
            }
        }

        sort(isec.begin(), isec.end());
        
        if (T >= 2) {
            cout << isec.back().first << "\n";
        }

        if (T == 3) {
            cout << 1 << "\n";
            cout << isec.back().second << " " << isec.back().first << "\n";
        }

        return 0;
    }

    
    vector<int> pos(n);
    for (int i = 0; i < n; ++i) {
        pos[i] = a[i + 1];
    }
    
    int ans = -1;
    
    set<pair<pair<int, int>, pair<vector<int>, string>>> st;
    function<void(int, int, vector<int>, string, bool)> rec = [&](int t, int mx, vector<int> a, string s, bool was) {
        if (st.count({{t, mx}, {a, s}})) return;
        if (t > 2 * m) return;
        
        st.insert({{t, mx}, {a, s}});

        for (int i = 0; i < n; ++i) {
            if (a[i] == 1) s[i] = 'R';
            if (a[i] == mx) s[i] = 'L';
        }

        bool done = 1;
        for (int i = 1; i < n; ++i) {
            if (a[i] != a[i - 1]) done = 0;
            if (s[i] != s[i - 1]) done = 0;
        }

        if (done) {
            ans = max(ans, mx);
            return;
        }

        int to = m;
        for (int i = 0; i < n; ++i) {
            to = min(to, a[i]);
        }

        if (!was) {
            for (int i = to + 1; i <= mx; ++i) {
                rec(t, i, a, s, 1);
            }
        }

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

        rec(t + 1, mx, a, s, 0);
    };

    rec(0, m, pos, s, 0);

    cout << ans << "\n";

    return 0;
}
