#include <bits/stdc++.h>

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(a) (int)(a.size())

#ifdef LOCAL
#define __lg(x) log2(x)
#endif

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

using namespace std;

void solve() {
    int T;
    cin >> T;
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    string s;
    cin >> s;

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

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

    vector<ll> cord(n);
    for (int i = 0; i < n; ++i) {
        if (mv[i] == 1) cord[i] = a[i];
        else cord[i] = m + m - a[i];
    }
    sort(all(cord));
    ll ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        ans = max(ans, (cord[i + 1] - cord[i]));
    }
    ans = max(ans, cord[0] + 2 * m - 2 - cord.back());
    cout << (ans) / 2 + 1 << '\n';

    auto dist = [&](ll x, ll y) -> ll {
        if (x <= y) return y - x;
        else return y + 2 * m - 2 - x;
    };

    if (T == 2) return;

    for (int i = 0; i < n; ++i) {
        if (dist(cord[i], cord[(i + 1) % n]) == ans) {
            vector<ll> b(n);
            int it = n - 1;
            for (int j = i; j >= 0; --j) {
                b[it--] = cord[j];
            }
            for (int j = n - 1; j > i; --j) {
                b[it--] = cord[j];
            }
            swap(a, b);
            break;
        }
    }

    int ind = 0;
    for (ll &i : cord) --i;
    ll cur_t = 0;
    ll add = 0;
    if (cord[n - 1] != m - 1) {
        int k;
        if (cord[n - 1] < m - 1) {
            k = m - 1 - cord[n - 1];
        } else {
            k = 3 * m - 3 - cord[n - 1];
        }
        for (ll &i : cord) i = (k + i) % (2 * m - 2);
        assert(cord[n - 1] == m - 1);
        add += k;
    }

    vector<pair<ll, int>> res;
    int sum = m;
    for (int i = n - 2; i >= 0; --i) {
        ll d = dist(cord[i], cord[i + 1]) / 2;
        if (d == 0) continue;
        cur_t += d;
        sum -= d;
        res.emplace_back(cur_t + add, sum);
    }
    cout << len(res) << '\n';
    for (auto i : res) cout << i.first << ' ' << i.second << '\n';
}

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

    int t = 1;
    // cin >> t;
    while (t--) solve();
}