#include<bits/stdc++.h>
#pragma GCC optimize("O3")
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

#define ll long long
#define debug(x) cerr << (#x) <<  " = " << x << "\n";
#define pb push_back
#define pii pair < int, int >
#define pll pair < ll, ll >
#define sz(x) (ll)(x.size())
#define all(x) x.begin(), x.end()

const int N = 5e5 + 5;
const int mod = 998244353;
const ll OO = 2e9;

using namespace std;
//using namespace __gnu_pbds;

//template<typename T>
//using oset = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T>
bool umx (T &a, T b) {
    return (a < b ? (a = b, 1) : 0);
}

template<typename T>
bool umn (T &a, T b) {
    return (a > b ? (a = b, 1) : 0);
}

int add (int x, int y) {
    x += y;
    if (x >= mod)
        x -= mod;
    return x >= 0 ? x : x + mod;
}

int mul (int x, int y) {
    return 1ll * x * y % mod;
}

int power (int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2)
            res = mul(res, x);
        x = mul(x, x);
        y >>= 1;
    }
    return res;
}

mt19937 rnd(42);

int T, n, m;
int A[N];
char D[N];

int apl (int x, int y, char d) {
    if (d == 'L') x -= y;
    if (d == 'R') x += y;
    return x;
}

int t = 0;

void solve (int &x, char &c, int &y, char &d) {
    int d0, d1;
    if (c == 'L')
        d0 = x - 1;
    else
        d0 = m - x;

    if (d == 'L')
        d1 = y - 1;
    else
        d1 = m - y;
    x = apl(x, min(d0,d1), c);
    y = apl(y, min(d0,d1), d);
    t += min(d0, d1);
}

pii find_p (int x, char c, int y, char d) {
    int cnt = 0;
    pii r0, r1, ans;
    while (1) {
        if (x > y) {
            swap(x, y);
            swap(c, d);
        }
        if (x == 1 && c == 'L')
            c = 'R';
        if (y == m && d == 'R')
            d = 'L';

        if (x == y && c == d) {
            ans = {t, m};
            break;
        }
        if (c == 'R' && d == 'L') {
            int k = (y + x) / 2;
            if (cnt == 1) r1 = {k, t + k - x};
            else r0 = {k, t + k - x};
            ++cnt;
            if (cnt == 2)
                break;

            t += k - x + 1;
            x = k + 1;
            y = k - 1;
            continue;
        }
        solve(x, c, y, d);
    }
    return max(r0, r1);
}

int a[N];
char d[N], dead[N];

void get (int &x, char &d, int ps) {
    int d0;
    if (d == 'L')
        d0 = x - 1;
    else
        d0 = m - x;
    ps -= d0;
    x = apl(x, d, ps);
    d = (d == 'L' ? 'R' : 'L');
    int ost = ps / (m - 1);
    ps %= (m - 1);
    if (ost)
        d = (d == 'L' ? 'R' : 'L');
    apl(x, d, ps);
}

int main () {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> T >> n >> m;
    set < int > kek;
    map < pair < int, char >, bool > mp;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        kek.insert(a[i] % 2);
    }
    int cnt = n;
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
        if (mp[{a[i], d[i]}]) dead[i] = 1, --cnt;
        mp[{a[i], d[i]}] = 1;
        A[i] = a[i];
        D[i] = d[i];

    }
    if (sz(kek) == 2) {
        cout << "No";
        return 0;
    }
    cout << "Yes\n";
    if (T == 1) return 0;
    vector < pii > ans;
    for (int it = 0; it < n; ++it) {
        if (cnt == 1) break;
        pii best = {0, 0};
        pii pr;
        for (int i = 0; i < n; ++i) {
            if (dead[i]) continue;
            for (int j = 0; j < n; ++j) {
                if (dead[j]) continue;
                if (umx(best, find_p(a[i], d[i], a[j], d[j]))) {
                    pr = {i, j};
                }
            }
        }
        ans.pb({best.second, best.first});
        dead[pr.second] = 1;
        for (int i = 0; i < n; ++i) {
            if (dead[i]) continue;
            a[i] = A[i], d[i] = D[i];
            get(a[i], d[i], t);
        }

    }

    if (ans[0].second == m) ans.clear();
    if (!sz(ans)) cout << m << "\n";
    else cout << ans[0].second << "\n";
    if (T == 2) return 0;

    cout << sz(ans) << "\n";
    for (auto [a, b] : ans)
        cout << a << " " << b << "\n";

}
