#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;

bool can(int n, int m, vi& b, string& t, vi& del) {
    vi a = b;
    string s = t;
    for (int we = 0; we <= 50; we++) {
        if (MAX(a) == MIN(a) && MIN(s) == MAX(s)) return true;
        while (!del.empty() && del.back() == we) {
            if (MAX(a) != m) {
                m--;
                del.pop_back();
            } else {
                return false;
            }
        }
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) s[i] = 'R';
            if (a[i] == m) s[i] = 'L';
        }
        if (MAX(a) == MIN(a) && MIN(s) == MAX(s)) return true;

        for (int i = 0; i < n; i++) {
            if (m == 1) continue;
            if (s[i] == 'L') a[i]--;
            else a[i]++;
        }
    }
//    exit(0);
    return false;
}


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 del;
    int ans = INF2;
    if (can(n,m,a,s,del)) ans = 0;


    //  exit(0);
    int odin = 1, dva = 2, tri = 3;
    for (int f = 0; f <= 30; f++) {
        del = {f};
        if (can(n,m,a,s,del)) {
            amin(ans, odin);
        }
        for (int t = f; t <= 30; t++) {
            del = {t, f};
            if (can(n,m,a,s,del)) amin(ans, dva);
            for (int k = t; k <= 30; k++) {
                del = {k, t, f};
                if (can(n,m,a,s,del))amin(ans, tri);
            }
        }
    }
    if (ans == INF2) {
        return -1;
    } else {
        return m - ans;
        cout << "Yes\n";
       // if (T >= 2) {
            cout << m - ans;
       // }
    }
}

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;
    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';
        }
        for (int i = 0; i < n; i++) {
            if (s[i] == 'L') a[i]--;
            else a[i]++;
        }
        if (a[0] == a[1]) {
            if (s[0] == s[1]) {
                return m;
            }
            if (mx < a[0]) {
                mx = a[0];
                wh = ti;
            }
        }
    }
    return mx;
}

void stress() {
    int n  = 2;
    for (int m = 7; 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 : " << sl << endl;
                            cout << "have : " << fa << 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;

    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;
    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]) {
            cnt++;
            if (s[0] == s[1]) {
                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(cnt <= 1);
    if (mx == -1) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        if (T >= 2) {
            cout << mx << '\n';
        }
        if (T == 3) {
            cout << "1\n";
            cout << wh << " " << mx << '\n';
        }
    }
   // return mx;
  //  cout << fast(n, m, a, s);


}

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();
    }
}