#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;
    }
    cout << "Yes";
    if(t == 1){
        return 0;
    }
    pair<long long, long long> aa = {-1, -1};
    long long tim = 0;
    long long cnt1 = -1;
    long long cnt2 = -1;
    if(ch1 == 'R'){
        cnt1 = 1;
    }
    if(ch2 == 'R'){
        cnt2 = 1;
    }
    if(x1 == x2){
        cout << '\n' << m << '\n';
        if(t == 2){
            return 0;
        }
        cout << 0;
        return 0;
    }
    for(long long i = 0; i < 10; i++){
        while(x1 != x2){
            tim++;
            x1 += cnt1;
            x2 += cnt2;
            if(x1 == m){
                cnt1 = -1;
            }
            if(x1 == 1){
                cnt1 = 1;
            }
            if(x2 == 1){
                cnt2 = 1;
            }
            if(x2 == m){
                cnt2 = -1;
            }
        }
        aa = max(aa, pair<long long, long long>{x2, tim});
        //cout << x2 << " " << tim << '\n';
        tim++;
        x1 += cnt1;
        x2 += cnt2;
        if(x1 == m){
            cnt1 = -1;
        }
        if(x1 == 1){
            cnt1 = 1;
        }
        if(x2 == 1){
            cnt2 = 1;
        }
        if(x2 == m){
            cnt2 = -1;
        }
    }
    cout << '\n' << aa.first << '\n';
    if(t == 2){
        return 0;
    }
    if(aa.second == m){
        while(1){}
    }
    cout << 1 << '\n' << aa.second << " " << aa.first;
}
