#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

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

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

// gp_hash_table<ll, ll> ht;

pair<ll, ll> get(ll pos, ll d, ll m, ll t) {
    t %= 2 * (m - 1);
    if (d == 0) {
        if (t <= pos - 1) {
            return {pos - t, t == pos - 1 ? 1 : 0};
        } else {
            return get(1, 1, m, t - pos + 1);
        }
    } else {
        if (t <= m - pos) {
            return {pos + t, t == m - pos ? 0 : 1};
        } else {
            return get(m, 0, m, t - m + pos);
        }
    }
}

void move2(ll& a, char& d, int m) {
    if (d == 'L') {
        --a;
        if (a == 1) {
            d = 'R';
        }
    } else {
        ++a;
        if (a >= m) {
            d = 'L';
        }
    }
}

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

    ll type;
    cin >> type;
    
    ll n, m;
    cin >> n >> m;
    if (n > 2) {
        exit(1);
    }

    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }
    string s;
    cin >> s;

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

    cout << "YES" << '\n';
    if (type == 1) {
        return 0;
    }

    ll res, t = 0;

    while (a[0] != a[1]) {
        ++t;
        move2(a[0], s[0], m);
        move2(a[1], s[1], m);

    }

    res = a[0];
    int t2 = t + 1;

    move2(a[0], s[0], m);
    move2(a[1], s[1], m);

    while (a[0] != a[1]) {
        ++t2;
        move2(a[0], s[0], m);
        move2(a[1], s[1], m);

    }

    cout << max(res, a[0]) << '\n';

    if (type == 2) {
        return 0;
    }

    if (res >= a[0]) {
        if (res == m) {
            cout << 0 << '\n';
            return 0;
        }
        cout << 1 << '\n';
        cout << t << ' ' << res << '\n';
    } else {
        if (a[0] == m) {
            cout << 0 << '\n';
            return 0;
        }
        cout << 1 << '\n';
        cout << t2 << ' ' << a[0] << '\n';
    }

    return 0;
}
