#include <bits/stdc++.h>

using namespace std;

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

#define int long long
#define pb push_back
#define all(a) a.begin(), a.end()
#define db long double
#define ff first
#define ss second
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define vvi vector<vi>

const int N = 5e5;
const int K = 20;
const int INF = 1e9;
const int mod = 998244353;
constexpr char nl = '\n';

// whos doper than this b1tch?

// андрея глазырина надо забанить почему он так стремно лыбит на меня

int bin_pow(int a, int p) {
    if (p < 0) {
        return 0;
    }
    if (p == 0) {
        return 1;
    }
    int res = 1;
    int pw = a;
    while (p) {
        if (p & 1) {
            res = res * pw % mod;
        }
        pw = pw * pw % mod;
        p >>= 1;
    }
    res %= mod;
    return res;
}

int sparse[K][N];

void build(vi a) {
    int n = a.size();
    for (int i = 0; i < n; ++i) {
        sparse[0][i] = a[i];
    }
    for (int k = 1; k < K; ++k) {
        for (int i = 0; i + (1 << k) <= n; ++i) {
            sparse[k][i] = max(sparse[k - 1][i], sparse[k - 1][i + (1 << (k - 1))]);
        }
    }
}

int get(int l, int r) {
    int k = __lg(r - l);
    return max(sparse[k][l], sparse[k][r - (1 << k)]);
}

void solve() {
    int T;
    cin >> T;
    int n, m;
    cin >> n >> m;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    string s;
    cin >> s;
    sort(all(a));
    a.erase(unique(all(a)), a.end());
    int f = a[0] % 2;
    for (int i = 0; i < n; ++i) {
        if (a[i] % 2 != f) {
            cout << "No";
            return;
        }
    }
    n = a.size();
    cout << "Yes\n";
    if (T == 1) return;
    vpii buf;
    int t = 0;
    int mx = m;
    int ans = 0;
    while (true) {
        int mx1 = *max_element(all(a));
        if (mx1 == mx) {
            int cnt = 0;
            for (int i = 0; i < n; ++i) {
                if (a[i] == mx1) {
                    cnt++;
                }
            }
            if (cnt > 1) {
                buf.pb({t, mx1});
                mx = mx1;
            }
            if (cnt == n) {
                ans = mx1;
                break;
            }
        }
        for (int i = 0; i < n; ++i) {
            if (a[i] == 1) {
                s[i] = 'R';
            }
            if (a[i] == mx) {
                s[i] = 'L';
            }
            if (s[i] == 'L') {
                a[i]--;
            } else {
                a[i]++;
            }
        }
        t++;
    }

    cout << ans << nl;
    if (T == 2) {
        return;
    }
    cout << buf.size() << nl;
    for (auto e: buf) {
        cout << e.ff << " " << e.ss << nl;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
