#include <bits/stdc++.h>

using namespace std;

int main() {
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    long long t;
    cin >> t;
    long long n, m;
    cin >> n >> m;
    long long x1, x2;
    char ch1, ch2;
    cin >> x1 >> x2 >> ch1 >> ch2;
    if(x1 % 2 != x2 % 2){
        cout << "No";
        return 0;
    }
    if(x1 > x2){
        swap(x1, x2);
        swap(ch1, ch2);
    }
    cout << "Yes" << '\n';
    if(t == 1){
        return 0;
    }
    if(ch1 == 'R' && ch2 == 'L'){
        long long x = (x1 + x2) / 2;
        long long dd = max(x, m + 1 - x);
        cout << max(x, m + 1 - x) << '\n';
        if(t == 3){
            cout << 1 << '\n' << max(dd - x1, x2 - dd) << " " << dd;
        }
    } else if(ch1 == 'R'){
        long long tt = m - x2;
        x1 += m - x2;
        x2 = m;
        long long x = (x1 + x2) / 2;
        long long dd = max(x, m + 1 - x);
        cout << max(x, m + 1 - x) << '\n';
        if(t == 3){
            cout << 1 << '\n' << tt + max(dd - x1, x2 - dd) << " " << dd;
        }
    } else if(ch2 == 'R'){
        long long goo = max(x1 - 1, m - x2);
        x2 += goo;
        x1 -= goo;
        if(x2 > m){
            long long del = (x2 - m);
            x2 -= 2 * del;
        }
        if(x1 < 1){
            long long del = (1 - x1);
            x1 += 2 * del;
        }
        long long x = (x1 + x2) / 2;
        long long dd = max(x, m + 1 - x);
        cout << max(x, m + 1 - x) << '\n';
        if(t == 3){
            
            cout << 1 << '\n' << goo + max(dd - x1, x2 - dd) << " " << dd;
        }
    } else{
        long long tt = x1 - 1;
        x1 = 1;
        x2 -= x1 - 1;
        long long x = (x1 + x2) / 2;
        long long dd = max(x, m + 1 - x);
        cout << max(x, m + 1 - x) << '\n';
        if(t == 3){
            cout << 1 << '\n' << tt + max(dd - x1, x2 - dd) << " " << dd;
        }
    }
}
