#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define int ll  

mt19937 rnd(52);

void solve() {
    int t; cin >> t;
    int n,m ; cin >> n >> m;
    vector<int> a(n);
    for (auto &u : a) cin >> u;

    string s; cin >> s;
    for (int j = 1; j < n; j++) {
        if(a[j]%2 != a[0]%2) {
            cout << "No\n";
            return;
        }
    }
    auto midpoint = [&](int x, int y)  {
        if (s[x] == s[y]) {
            int pt = abs(a[x] - a[y]) / 2;
            return m - pt;
        }
        if (a[x] > a[y]) swap(x, y);
        if (s[x] == 'R') {
            int pt= (a[x] + a[y]) / 2;
            return max(pt, m + 1 - pt);
        }
        int cl = min(a[x] - 1, m - a[y]);
        int pt1 = a[x] - cl, pt2 = a[y] + cl;
        int kek = (pt2 - pt1) / 2;
        return m - kek;
    };  
    auto where = [&](int x, int y) -> pair<int, int>{
        int dir = (s[x] == 'L' ? 0 : 1), ps = a[x];
        while (true) {
            if (dir == 0) {
                if (ps - 1 >= y) return {ps - y, 0};

                y -= (ps - 1);
                ps = 1;
                dir = 1;
            } else {    
                if (m - ps >= y) return{ps + y, 1};
                y -= (m - ps);
                ps = m;
                dir = 0;
            }
        }
    };
    auto tim = [&](int x, int y) {
        int spent = 0, pos = a[x], dir = (s[x] == 'L' ? 0 : 1);
        vector<int> times;
        for (int it = 0; it < 10; it++){
            if (dir == 0) {
                if (pos>=  y) times.pb(spent+pos-y);
                spent += pos - 1;
                pos = 1;
                dir = 1;
            } else {
                if (pos <= y) times.pb(spent + y - pos);
                spent += m - pos;
                pos = m;
                dir = 0;
            }
        }
        return times;
    };
    cout<< "Yes\n";
    if (t == 1) return;
    vector<int> par(n), siz(n, 1); iota(all(par), 0);
    auto get = [&](int v) {
        while (par[v] != v){
            v = par[v] = par[par[v]];
        }
        return v;
    };
    auto merge = [&](int u, int v) -> bool {
        u = get(u); v = get(v);
        if (u == v) return false;
        if (siz[u] < siz[v]) swap(u, v);
        par[v] = u;
        siz[u] += siz[v];
        return true;
    };

    set<pair<int, int>> st;
    vector<pair<int, int>> A;
    for (int i = 0; i < n; i++) {
        pair<int, int> pr = {a[i], (s[i] == 'L' ? 0 : 1)};
        if (pr.first == 0 && pr.second == 0) pr.second = 1;
        if (pr.first == m && pr.second == 1) pr.second = 0;
        if(st.find(pr) == st.end()) {
            A.pb(pr);
        } 
        st.insert(pr);
    }

    sort(all(A));

    n = sz(A);
    for (int j = 0; j < sz(A); j++) {
        a[j] = A[j].first;
        s[j] = (A[j].second ? 'R' : 'L');
    }

    vector<array<int, 3>> edges;
    vector<int> last(2, -1);

    for(int i = 0; i < n; i++) {
        int cr = (s[i] == 'R' ? 1 : 0);
        for (int pp = 0; pp < 2; pp++) {
            if(last[pp] == -1) continue;
            int mp = midpoint(i, last[pp]);
            edges.pb({mp, i, last[pp]});
        }
        last[cr] = i;
    }

    // for (int i = 0; i<n; i++) {
    //     for (int pp = 0; pp < 2; pp++) {
    //         if(last[pp] == -1) continue;
    //         int mp = midpoint(i, last[pp]);
    //         edges.pb({mp, i, last[pp]});
    //     }
    // }

    // last.assign(2, -1);
    // for(int i = n - 1; i >= 0; i--) {
    //     int cr = (s[i] == 'R' ? 1 : 0);
    //     for (int pp = 0; pp < 2; pp++) {
    //         if(last[pp] == -1) continue;
    //         int mp = midpoint(i, last[pp]);
    //         edges.pb({mp, i, last[pp]});
    //     }
    //     last[cr] = i;
    // }
    // for (int i = 0; i<n; i++) {
    //     for (int pp = 0; pp < 2; pp++) {
    //         if(last[pp] == -1) continue;
    //         int mp = midpoint(i, last[pp]);
    //         edges.pb({mp, i, last[pp]});
    //     }
    // }

    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < 100; j++) {
    //         int u = rnd()%n;
    //          int mp = midpoint(i, u);
    //         edges.pb({mp, i, u});
    //     }
    // }
    
    // int best =m+1;
    for (int i = 0; i < n; i++) {

        ll sm = 0;
        for (int j = i + 1; j < n; j++) if (j != i && s[j] != s[i]) edges.pb({midpoint(i, j), i, j});
        // best = min(best, sm);
    }
    sort(all(edges)); reverse(all(edges));
    int cmp = n;
    ll smw = 0;
    vector<pair<int, int>> ANS;
    int TM = 0, M = m;
    for(auto [w, i, j] : edges) {
        int rs = merge(i, j);
        if (rs) {
            cmp -= rs;
            smw += rs * (M-w);

            if (cmp == 1) {
                cout << M-smw << '\n';;
            }
        }
    }
    if (cmp == 1) {
        cout << M-smw << '\n';;
    }
}

signed main() {
    int t = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> t;
    #else 
        cin.tie(0)->sync_with_stdio(false);
    #endif 

    while (t--) solve();

    return 0;
}