#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;

const int INF = 1e9, MAXN = 1e5, mod = 998244353;

void solve();

int gg;

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int tt = 1;
    cin >> gg;
    // cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}

int mx_m = -INF;
vector<pair<int, int> > ans;

void solve() {
    int n, m;
    cin >> n >> m;
    m--;
    vector<int> arr(n);
    string s;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        arr[i]--;
    }
    cin >> s;


    bool check = true;
    for (int i = 1; i < n; i++) {
        if (arr[i] % 2 != arr[i - 1] % 2) {
            check = false;
        }
    }
    if (!check) {
        cout << "No";
        return;
    }
    cout << "Yes\n";

    int mx_r = -INF;
    vector<pair<int, int> > ans;
    int cnt = -1;
    while (cnt != 1e6) {
        cnt++;
        check = true;
        for (int i = 1; i < n; i++) {
            if (arr[i] != arr[i - 1]) {
                check = false;
            }
        }
        if (check && mx_r < arr[0]) {
            mx_r = arr[0];
            ans = {{cnt, mx_r}};
        }
        for (int i = 0; i < n; i++) {
            if (s[i] == 'R') {
                arr[i]++;
            } else {
                arr[i]--;
            }
        }

        for (int i = 0; i < n; i++) {
            if (arr[i] == 0 && s[i] == 'L') {
                s[i] = 'R';
            }
            if (arr[i] == m && s[i] == 'R') {
                s[i] = 'L';
            }
        }
    }
    if (gg >= 2) {
        cout << mx_r + 1 << '\n';
    }
    if (gg >= 3) {
        cout << ans.size() << '\n';
        for (auto [t, m]: ans) {
            cout << t << ' ' << m + 1 << '\n';
        }
    }
}
