#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    int n, m;
    cin >> n >> m;
    assert(n == 2);
    assert(m <= 200000);
    vector<int> a(n);
    for (auto& i : a) cin >> i;
    string s;
    cin >> s;
    if (a[0] % 2 != a[1] % 2) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    int best = -1;
    pair<int, int> ans;
    for (int ti = 0; ti <= 8 * m; ti++) {
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) {
                s[i] = 'R';
            }
            if (a[i] == m) {
                s[i] = 'L';
            }
        }
        bool check = true;
        for (int i = 0; i < n; i++) {
            check &= a[0] == a[i];
        }
        if (check) {
            if (a[0] > best) {
                ans = {a[0], ti};
                best = a[0];
            }
        }
        for (int i = 0; i < n; i++) {
            if (s[i] == 'L') a[i]--;
            else a[i]++;
        }
    }
    cout << ans.first << '\n';
    cout << 1 << '\n';
    cout << ans.second << ' ' << ans.first << '\n';
}
