#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);
        }
    }
}

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 x;
    ll t;

    if (a[0] > a[1]) {
        swap(a[0], a[1]);
    }

    if (a[0] == a[1]) {
        x = a[0];
        t = 0;
    } else if (a[0] < a[1] && s[0] == 'R' && s[1] == 'L') {
        x = (a[0] + a[1]) / 2;
        t = x - a[0];
    } else {
        if (s[0] == s[1] && s[0] == 'R') {
            t = m - a[1];
            auto [p1, d1] = get(a[0], 1, m, t);
            auto [p2, d2] = get(a[1], 1, m, t);
            x = (p1 + p2) / 2;
            t += x - p1;
        } else if (s[0] == s[1] && s[0] == 'L') {
            t = a[0] - 1;
            auto [p1, d1] = get(a[0], 0, m, t);
            auto [p2, d2] = get(a[1], 0, m, t);
            x = (p1 + p2) / 2;
            t += p2 - x;
        } else {
            t = max(m - a[1], a[0] - 1);
            auto [p1, d1] = get(a[0], 0, m, t);
            auto [p2, d2] = get(a[1], 0, m, t);
            x = (p1 + p2) / 2;
            t += x - p1;
        }
    }

    cout << max(x, m - x + 1) << '\n';
    
    if (type == 2) {
        return 0;
    }

    if (x >= m - x + 1) {
        if (x == m) {
            cout << 0 << '\n';
            return 0;
        }
        cout << 1 << '\n';
        cout << t << ' ' << x << '\n';
    } else {
        if (m - x + 1 == m) {
            cout << 0 << '\n';
            return 0;
        }
        cout << 1 << '\n';
        
        auto [p1, d1] = get(a[0], s[0] == 'R' ? 1 : 0, m, t);
        auto [p2, d2] = get(a[1], s[1] == 'R' ? 1 : 0, m, t);

        // cout << p1 << ' ' << d1 << ' ' << p2 << ' ' << d2 << '\n';

        ll t2 = 0;
        if (d1 == 0) {
            t2 = max(t2, p1 - 1);
        } else {
            t2 = max(t2, m - p1);
        }

        if (d2 == 0) {
            t2 = max(t2, p2 - 1);
        } else {
            t2 = max(t2, m - p2);
        }

        // cout << "dfsds " << t2 << '\n';
        auto [p3, d3] = get(p1, d1, m, t2);
        auto [p4, d4] = get(p2, d2, m, t2);
        x = (p3 + p4) / 2;
        t2 += t + x - min(p3, p4);
        cout << t2 << ' ' << x << '\n';
    }

    return 0;
}
