#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    int n, m;
    cin >> n >> m;
    int a1, a2;
    cin >> a1 >> a2;
    char c1, c2;
    cin >> c1 >> c2;
    if (a1 % 2 != a2 % 2) {
        cout << "No";
        return 0;
    }
    cout << "Yes\n";
    if (a1 == a2 && c1 == c2) {
        if (t == 1)return 0;
        cout << m << '\n';
        if (t == 2)return 0;
        cout << 0;
        return 0;
    }
    int tim = 0;
    int st1 = -1, st2 = -1, t1 = -1, t2 = -1;
    while (true) {
        if (a1 == a2) {
            if (st1 == -1) {
                st1 = a1, t1 = tim;
            } else {
                st2 = a1, t2 = tim;
                break;
            }
        }
        tim++;
        if (c1 == 'L') {
            if (a1 == 1) {
                a1 = 2;
                c1 = 'R';
            } else {
                a1--;
            }
        } else {
            if (a1 == m) {
                a1 = m - 1;
                c1 = 'L';
            } else {
                a1++;
            }
        }

        if (c2 == 'L') {
            if (a2 == 1) {
                a2 = 2;
                c2 = 'R';
            } else {
                a2--;
            }
        } else {
            if (a2 == m) {
                a2 = m - 1;
                c2 = 'L';
            } else {
                a2++;
            }
        }
    }
    if (t == 1)return 0;
    cout << max(st1, st2) << '\n';
    if (t == 2)return 0;
    cout << 1 << "\n";
    if (st1 == max(st1, st2)) {
        cout << t1 << " " << st1;
    } else {
        cout << t2 << " " << st2;
    }
}
