#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using V = vector<ll>;
using VV = vector<V>;
using VVV = vector<VV>;
using VVVV = vector<VVV>;
using P = pair<ll,ll>;
using VP = vector<P>;
using VVP = vector<VP>;
using VVVP = vector<VVP>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define Alexander_Babin int main()
#define Philipp_Gribov void solve()
#define Vorg_Cup void build()
#define Ivan_Argunov ull binpow(ull a, ull n)

mt19937 rnd('zalupa');
const ull base = 83;
const ull mod = 998244353;
Ivan_Argunov {
    ull ans = 1;
    while (n) {
        if (n&1) ans = ans * a % mod;
        n >>= 1;
        a = a * a % mod;
    }
    return ans;
}
ull pows[1000001];
ull rpows[1000001];
ull fact[1000001];
ull rfact[1000001];
Vorg_Cup {
    pows[0] = 1;
    rpows[0] = 1;
    fact[0] = 1;
    rfact[0] = 1;
    for (int i=1;i<=1000000;i++) {
        pows[i] = pows[i-1] * base;
        fact[i] = fact[i-1] * i;
        //pows[i] = pows[i-1] * base % mod;
        //rpows[i] = binpow(pows[i], mod-2);
        //fact[i] = fact[i-1] * i % mod;
        //rfact[i] = binpow(fact[i], mod-2);
    }
}

struct sparse_table {
    int n;
    V a;
    VV sparses;
    void init(V _a){
        a = _a;
        n = _a.size();
        sparses.assign(__lg(n)+1,V(n));
        sparses[0] = _a;
        for (int j=1;j<=__lg(n);j++)
            for (int i=0;i+(1<<j)-1<n;i++)
                sparses[j][i]=min(sparses[j-1][i],sparses[j-1][i+(1<<(j-1))]);
    }
    int get(int l, int r) {
        int x = __lg(r-l+1);
        return min(sparses[x][l],sparses[x][r-(1<<x)+1]);
    }
};

struct furry_tree {
    int n;
    V a;
    V val;
    void upd(int i, int x) {
        for (;i<=n;i+=i&(-i))
            val[i]+=x;
    }
    void init(int _n) {
        n = _n;
        a.assign(n,0);
        val.assign(n+1,0);
    }
    // void init(V _a) {
    //     a = _a;
    //     n = _a.size();
    //     val.assign(n+1,0);
    //     for (int i=0;i<n;i++)
    //         upd(i+1,a[i]);
    // }
    int gett(int r) {
        int ans = 0;
        for (;r>0;r-=r&(-r))
            ans+=val[r];
        return ans;
    }
    int get(int l, int r) {
        return gett(r+1)-gett(l);
    }
};

// int m;
// vector<unordered_map<int,int>> big_furry_tree;
//
// void upd(int i, int j, int x) {
//     for (;i<=m;i+=i&-i) {
//         for (;j<=m;j+=j&-j) {
//             if (!big_furry_tree[i].count(j))
//                 big_furry_tree[i][j]=0;
//             big_furry_tree[i][j]+=x;
//         }
//     }
// }
//
// int get(int ri, int rj) {
//     int ans=0;
//     for (;ri>0;ri-=ri&-ri)
//         for (;rj>0;rj-=rj&-rj)
//             if (big_furry_tree[ri].count(rj))
//                 ans+=big_furry_tree[ri][rj];
// }

// VV fenwick;
//
// void add(int i, int j) {
//     for (;i<=m;i+=i&-i)
//         fenwick[i].push_back(j);
// }
//
// int get(int i, int j) {
//     int ans=0;
//     for (;i>0;i-=i&-i)
//         ans+=lower_bound(fenwick[i].begin(),fenwick[i].end(),j)-fenwick[i].begin();
//     return ans;
// }


Philipp_Gribov {
    int t; cin >> t;
    int n,m; cin >> n >> m;
    int a,b; cin >> a >> b; a--; b--;
    char c,d; cin >> c >> d;
    if (c=='L' and a!=0 and a!=m-1)
        a=2*n-a-2;
    if (d=='L' and b!=0 and b!=m-1)
        b=2*n-b-2;
    int delta=(a-b+2*n-2)%(2*n-2);
    if (delta%2==1) {
        cout << "No";
    } else {
        cout << "Yes" << '\n';
        if (t==1) return;
        int goal = max(n+delta/2-1,delta/2);
        cout << goal+1 << '\n';
        if (t==2) return;
        cout << 1 << '\n';
        cout << (goal-a+2*n-2)%(2*n-2) << ' ' << goal+1 << '\n';
    }
}

Alexander_Babin {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        cout << '\n';
    }
}
