#pragma GCC optimize("O3,unroll-loops")
#include<vector>
#pragma GCC target("avx,avx2")
#include<bits/stdc++.h>
using namespace std;

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

#ifdef DBG
#define $(x) x
#else
#define $(x)
#endif

#define debug(x) $(cout << #x << " = " << x << endl)

#define all(x) x.begin(), x.end()

constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1e18 + 7;

void WA() {
    cout << "THIS IS WRONG ANSWER" << endl;
    exit(0);
}

void RE() {
    exit(1);
}

void TL() {
    unsigned x = 0;
    while (true) x++;
}

void No() {
    cout << "No\n";
}

void Yes() {
    cout << "Yes\n";
}

void solve() {
    int t;
    cin >> t;
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        p[i]--;
    }
    vector<bool> d(n);
    for (int i = 0; i < n; ++i) {
        char r;
        cin >> r;
        d[i] = r == 'R';
    }

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        if (d[i]) {
            a[i] = p[i] + m - 1;
        } else {
            a[i] = m - p[i] - 1;
        }
        debug(a[i]);
    }
    bool ex[2] = {0, 0};

    for (int i = 0; i < n; ++i) {
        ex[a[i] & 1] = 1;
    }

    if (ex[0] && ex[1]) {
        No();
        return;
    }

    Yes();
    if (t == 1) return;

    sort(all(a));
    int mxi = n - 1;
    int mx = (m - 1) * 2 - a.back() + a.front();
    for (int i = 0; i < n - 1; ++i) {
        if (mx < a[i + 1] - a[i]) {
            mx = a[i + 1] - a[i];
            mxi = i;
        }
    }

    int sps = (2 * (m - 1) - mx) / 2;

    cout << m - sps << '\n';

    if (t == 2) return;

    

    vector<pair<ll, int>> ops;
    int b = (mxi + 1) % n;
    int mem = a[b];
    rotate(a.begin(), a.begin() + b, a.end());
    assert(*a.begin() == mem);

    reverse(all(a));

    ll ct = 0;
    
    while (a.size() >= 2) {
        int l = 2 * (m - 1);
        int i = a.back();
        a.pop_back();
        int d = (a.back() - i) % l;
        ct += m - d / 2;
        ops.push_back({ct, m - d / 2});
        m -= d / 2;
    }

    cout << ops.size() << '\n';
    for (auto [a, b] : ops) {
        cout << a << ' ' << b << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    $(cin >> t);
    while (t--) {
        debug("=-=-=-=-=-=-=-=");
        solve();
    }
}