#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using ld=long double;
using ull=unsigned long long;
using lll=__int128;

#ifdef LOCAL
#define deb(x) cout<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
#else
#define deb(x)
#endif
#define all(x) x.begin(), x.end()
#define arr(x) x.rbegin(), x.rend()
#define int ll
int get(int T, string g, int n, int m, vector<int> a) {
    //int T;
    //cin>>T;
    //int n,m;
    //cin>>n>>m;
    //vector<int> a(n);
    //for (auto i=0; i<n; ++i) cin>>a[i];
    for (auto i=0; i<n; ++i) {
        if ((a[i]+a[0])%2) {
            cout<<"No";
            exit(0);
        }
    }
    int t=0;
    if (g[0]=='R') {
        t=m-a[0];
        g[0]='L';
        a[0]=m;
    }
    t+=a[0]-1;
    a[0]=1;
    if (g[1]=='R') {
        a[1]+=t;
        if (a[1]>=m) {
            a[1]=2*m-a[1];
            g[1]='L';
        }
        if (a[1]<=0) {
            a[1]=2-a[1];
            g[1]='R';
        }
        
    }else {
        a[1]-=t;
        if (a[1]<=0) {
            a[1]=2-a[1];
            g[1]='R';
        }
        if (a[1]>=m) {
            a[1]=2*m-a[1];
            g[1]='L';
        }
    }
    g[0]='R';
    if (g[1]=='R') {
        t+=m-a[1];
        a[0]+=m-a[1];
        a[1]=m;
    }
    int x=(a[0]+a[1])/2;
    t+=x-a[0];        
    if (x<m-x+1) {
        t+=m-1;
        x=m-x+1;
    }
    return x;
}
random_device rd;
mt19937 rnd(rd());
int get1(int end, deque<int> l, deque<int> r, int m, int f) {
    sort(all(l));
    l.resize(unique(all(l))-l.begin());
    sort(all(r));
    r.resize(unique(all(r))-r.begin());
    vector<pair<int,int>> an;
    int t=0;
    int cnt=0;
    while (l.size()+r.size()>1) {
        cnt++;
        while (l.size() && r.size() && r.back()<=l.back() && (l.back()+r.back())/2>=end) {
            int x=(l.back()+r.back())/2;
            cnt=0;
            int w=x-r.back();
            t+=w;
            an.push_back({t,x+1});
            m=x;
            for (auto& i: r) i+=w;
            for (auto& i: l) i-=w;
            while (l.size() && l[0]<=0) {
                r.push_front(-l[0]);
                l.pop_front();
            }
            while (r.size() && r.back()==m) {
                r.pop_back();
            }
        }
        if (cnt==l.size()+r.size()+2) {
            break;
        }
        if (l.size() && (r.size()==0 || l[0]<m-r.back())) {
            int w=l[0];
            t+=w;
            while (l.size() && l[0]==w) {
                l.pop_front();
                r.push_front(-w);
            }
            for (auto& i: r) i+=w;
            for (auto& i: l) i-=w;
        }else {
            int w=m-r.back();
            t+=w;
            while (r.size() && r.back()==m-w) {
                r.pop_back();
                l.push_back(m+w);
            }
            for (auto& i: r) i+=w;
            for (auto& i: l) i-=w;
        }
    }
    if (f) {
        cout<<m+1<<endl;
        if (f==3) {
            cout<<an.size()<<endl;
            for (auto i: an) cout<<i.first<<' '<<i.second<<endl;
        }
        exit(0);
    }
    if (l.size()+r.size()>1) return 0;
    return 1;
}
signed main(){
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int cntt=0;
    bool deb=0;
    while (1) {
    int T=2;
    cntt++;
    if (deb) cout<<"TEST "<<cntt<<endl;
    if (!deb) cin>>T;
    int n,m;
    if (!deb)cin>>n>>m;
    else {
        n=2;
        m=rnd()%6+1;
    }
    vector<int> a(n);
    if (!deb)for (auto i=0; i<n; ++i) {
        cin>>a[i];
    }else {
        a[0]=rnd()%m+1;
        while (1) {
            a[1]=rnd()%m+1;
            if ((a[1]+a[0])%2) {
                continue;
            }
            break;
        }
    }
    for (auto i=0; i<n; ++i) {
        if ((a[i]+a[0])%2) {
            cout<<"No";
            exit(0);
        }
    }
    if (!deb) cout<<"Yes\n";
    if (T==1) {
        exit(0);
    }
    string g;
    if (!deb) cin>>g;
    else {
        for (auto& i: a) {
            if (i==1 || i!=m && rnd()%2) g+='R';
            else g+='L';
        }
    }
    int ans=0;
    int mm=m;
    if (deb) ans=get(T,g,n,m,a);
    deque<int> l,r;
    m--;
    for (auto i=0; i<n; ++i) {
        if (g[i]=='L') l.push_back(a[i]-1);
        else r.push_back(a[i]-1);
    }
    sort(all(l));
    sort(all(r));
    int lq=0, rq=m+1;
    while (lq+1!=rq) {
        int mq=(lq+rq)/2;
        if (get1(mq,l,r,m,0)) lq=mq;
        else rq=mq;
    }
    if (!deb) get1(lq,l,r,m,T);
    else {
        if (ans!=rq) {
            cout<<T<<endl;
            cout<<n<<' '<<mm<<endl;
            for (auto i=0; i<n; ++i) cout<<a[i]<<' ';
            cout<<endl;
            cout<<g<<endl;
            cout<<ans<<' '<<rq<<endl;
            exit(0);
        }
    }
}
}