#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("avx2")
template<typename T>
istream& operator>>(istream& stream, vector<T>& a) {
    for (auto& x : a) stream >> x;
    return stream;
}
template<typename T>
ostream& operator<<(ostream& stream, vector<T>& a) {
    for (auto& x : a) stream << x << ' ';
    cout << '\n';
    return stream;
}
template<typename T1, typename T2>
istream& operator>>(istream& stream, vector<pair<T1, T2>>& a) {
    for (auto& [x, y] : a) stream >> x >>  y;
    return stream;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& stream, vector<pair<T1, T2>>& a) {
    for (auto& [x, y] : a) stream << x << ' ' << y << '\n';
    return stream;
}
template<typename T1, typename T2>
inline void amax(T1& a, T2 b) {
    a = max(a, b);
}
template<typename T1, typename T2>
inline void amin(T1& a, T2 b) {
    a = min(a, b);
}

#define int int64_t
#define all(x) x.begin(), x.end()
#define pb emplace_back
#define ff first
#define ss second
#define sz(x) (int)(x.size())
#define deb cout << "----------------------" << endl
#define MIN(x) *min_element(all(x))
#define MINID(x) min_element(all(x)) - x.begin()
#define MAX(x) *max_element(all(x))
#define MAXID(x) max_element(all(x)) - x.begin()
#define push emplace
#define SUM(x) accumulate(all(x), 0ll)
#define sj(x) sort(all(x)), x.erase(unique(all(x)), x.end())

mt19937 rnd(221);

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
using ld = long double;

const int64_t INF = 5e15;
const int INF2 = 1e9;
const int mod = 1e9+7;
const ld eps = 1e-6;

const int N = 2e6 + 2323;
const int D = 500;


int slow(int n, int m, vi a, string s) {
    for (int i =0 ;i < n; i++) {
        if (a[i] == 1) s[i] = 'R';
        if (a[i] == m) s[i] = 'L';
    }
    vi can;
    int d = abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);
    d = a[0] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);

    d = a[1] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);

    d = m - a[0] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);
    d = m - a[1] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);

    d = m - a[1] + a[0] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);

    d = m - a[0] + a[1] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);


    can.pb(0);
    int ma = -1;
    sj(can);
    int t = sz(can);
    for (int i = 0; i <t; i++) {
        can.pb(can[i] + m);
    }
    for (auto x : can) {

        vi go(2), st(2);
        for (int i = 0; i < 2; i++) {
            go[i] = a[i];
            if (s[i] == 'L') st[i] = 0;
            else st[i] = 1;
            int te = x;
//deb;
            while (te > 0) {
                if (go[i] == 1) {
                    int pr = min(te, m - 2);
                    go[i] += pr;
                    st[i] = 1;
                    te-=pr;
                } else if (go[i] == m) {
                    int lv = min(te, m - 2);
                    go[i]-=lv;
                    st[i] = 0;
                    te-=lv;
                } else {
                    if (st[i] == 0) {
                        int lv = min(te, go[i] - 1);
                        go[i]-=lv;
                        st[i] = 0;
                        te-=lv;
                    } else {
                        int pr = min(te, m - go[i]);
                        go[i] += pr;
                        st[i] = 1;
                        te-=pr;
                    }
                }
            }
        }
        int wh1 = go[0], wh2 = go[1];
        int cuda1 = st[0], cuda2 = st[1];
       // cout << x << " " << wh1 << " " << wh2 << endl;
       // cout << cuda1 << " " <<cuda2 << endl;
        if (wh1 == wh2) {
            //cout << cuda1 << " " << cuda2 << endl;
            if (wh1 == 1 || wh1 == m || cuda1 == cuda2) {
                return m;
            } else {
                amax(ma, wh1);
            }
        }
    }

    return ma;
}

int fast(int n, int m, vi a, string s) {

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) s[i] = 'R';
        if (a[i] == m) s[i] = 'L';
    }
    int mx = -1, wh = -1;
    int cnt = 0;
    set<int> st;
    for (int ti = 0; ti < n * m * 4; ti++) {
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) s[i] = 'R';
            if (a[i] == m) s[i] = 'L';
        }
        // cout << ti << " : " << a;
        if (a[0] == a[1]) {
            st.insert(a[0]);
            if (s[0] == s[1]) {
                return m;
                /*
                cout << "Yes\n";
                if (T >= 2) {
                    cout << m << '\n';
                }
                if (T == 3) {
                    cout << "0\n";
                }
                return;*/
            }
            if (mx < a[0]) {
                mx = a[0];
                wh = ti;
            }
        }

        for (int i = 0; i < n; i++) {
            if (s[i] == 'L') a[i]--;
            else a[i]++;
        }
    }
    assert(sz(st) <= 2);
    if (mx == -1) {
        return -1;
        cout << "No\n";
    } else {
        return mx;
        /*
        cout << "Yes\n";
        if (T >= 2) {
            cout << mx << '\n';
        }
        if (T == 3) {
            cout << "1\n";
            cout << wh << " " << mx << '\n';
        }*/
    }
}

void stress() {
    int n  = 2;
    for (int m = 2; m <= 10; m++) {
        for (int f = 1; f <= m; f++) {
            for (int s = 1; s <= m; s++) {
                for (int f1 = 0; f1 < 2; f1++) {
                    for (int s1 = 0; s1 < 2; s1++) {
                        vi a = {f, s};
                        string se;
                        if (f1 == 0) se+='L';
                        else se += 'R';

                        if (s1 == 0) se+='L';
                        else se += 'R';

                        int sl = slow(n, m, a, se);
                        int fa = fast(n, m, a, se);
                        if (sl != fa) {
                            cout << n << " " << m << '\n';
                            cout << a;
                            cout << se << endl;
                            cout << "need : " << fa << endl;
                            cout << "have : " << sl << endl;
                            deb;
                            exit(0);
                        }
                    }
                }
            }
        }
    }
    cout << "goooooooooooo" << endl;
    deb;
}

void solve() {
 //  stress();
    int T; cin >> T;
    int n, m; cin >> n >> m;
    int M = m;
    vi a(n); cin >> a;
    string s; cin >> s;

   // return mx;
    for (int i =0 ;i < n; i++) {
        if (a[i] == 1) s[i] = 'R';
        if (a[i] == m) s[i] = 'L';
    }
    vi can;
    int d = abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);
    d = a[0] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);

    d = a[1] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);

    d = m - a[0] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);
    d = m - a[1] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);

    d = m - a[1] + a[0] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);

    d = m - a[0] + a[1] + abs(a[0] - a[1]);
    can.pb(d / 2);
    can.pb(d / 2 + 1);


    can.pb(0);
    int ma = -1;
    sj(can);
    int t = sz(can);
    for (int i = 0; i <t; i++) {
        can.pb(can[i] + m);
    }
    int wher;
    for (auto x : can) {

        vi go(2), st(2);
        for (int i = 0; i < 2; i++) {
            go[i] = a[i];
            if (s[i] == 'L') st[i] = 0;
            else st[i] = 1;
            int te = x;
//deb;
            while (te > 0) {
                if (go[i] == 1) {
                    int pr = min(te, m - 2);
                    go[i] += pr;
                    st[i] = 1;
                    te-=pr;
                } else if (go[i] == m) {
                    int lv = min(te, m - 2);
                    go[i]-=lv;
                    st[i] = 0;
                    te-=lv;
                } else {
                    if (st[i] == 0) {
                        int lv = min(te, go[i] - 1);
                        go[i]-=lv;
                        st[i] = 0;
                        te-=lv;
                    } else {
                        int pr = min(te, m - go[i]);
                        go[i] += pr;
                        st[i] = 1;
                        te-=pr;
                    }
                }
            }
        }
        int wh1 = go[0], wh2 = go[1];
        int cuda1 = st[0], cuda2 = st[1];
       // cout << x << " " << wh1 << " " << wh2 << endl;
       // cout << cuda1 << " " <<cuda2 << endl;
        if (wh1 == wh2) {
            //cout << cuda1 << " " << cuda2 << endl;
            if (wh1 == 1 || wh1 == m || cuda1 == cuda2) {
                cout << "Yes\n";
                if (T >= 2) {
                    cout << m << "\n";
                }
                if (T == 3) {
                    cout << "0\n";
                }
                return;
            } else {
                if (ma < wh1) {
                    ma = wh1;
                    wher = x;
                }
            }
        }
    }

    if (ma == -1) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        if (T  >= 2) {
            cout << ma << '\n';
        }
        if (T  == 3) {
            cout << "1\n";
            cout << wher << " " << ma << '\n';
        }
    }


}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    int tt = 1;
    // cin >> tt;
    while (tt--) {
        solve();
    }
}