#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <vector>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using ld = long double;
const ll maxn = 500'000, inf = 1'000'000'000'000, mod = 998'244'353;
struct ani {
    ll x;
    char nap;
};
ll dist(ani a, ll fin) {
    if (a.nap == 'L') {
        return (a.x - 1) + (fin-1);
    } else {
        return fin - a.x;
    }
}
int main() {
    cin.tie(0)->sync_with_stdio(0);
#ifdef DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ll t; cin >> t;
    ll n, m; cin >> n >> m;
    if (t == 1) {
        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        bool f = 1;
        for (int i = 1; i < n; ++i) {
            if ((a[i] - a[i - 1]) % 2 == 1) f = 0;
        }
        if (f) cout << "Yes";
        else cout << "No";
        return 0;
    }
    //n==2
    vector<ani> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].x;
    }
    for (int i = 0; i < n; ++i) {
        char c; cin >> c;
        a[i].nap = c;
    }
    if (abs(a[0].x - a[1].x) % 2 == 1) {
        cout << "No";
        return 0;
    }
    cout << "Yes\n";
    /*cout << (m / 2 + 1) << '\n';
    if (t == 3) {
        cout << 1 << '\n';
        cout << m / 2 << ' ' << (m/2 + 1);
        return 0;
    }*/
    vector<vector<ll>> arr(n, vector<ll> (m));
    a[0].x -= 1;
    a[1].x -= 1;
    if (m == 1) {
        cout << 1 << '\n';
        if (t == 3) {
            cout << "1 0 1";
        }
        return 0;
    }
    ll ans2 = 0;
    vector<pair<ll, ll>> ans3;
    for (int i = 0 ; i < n; ++i) {
        if (a[i].x == 0) {
            a[i].nap = 'R';
        } else if (a[i].x == m-1) {
            a[i].nap = 'L';
        }
    }
    for (int t_cur = 0; t_cur < 5 * m + 1; ++t_cur) {
        if (a[0].x == a[1].x) {

            if (ans2 < a[0].x+1) {
                ans2 = max(ans2, a[0].x+1);
                ans3 = {{t_cur, a[0].x+1}};
            }
        }
        for (int i = 0 ; i < n; ++i) {
            if (a[i].nap == 'L') {
                if (a[i].x == 0) {
                    a[i].nap = 'R';
                    a[i].x = 1;
                }
                else {
                    a[i].x--;
                }
            } else {
                if (a[i].x == m-1) {
                    a[i].nap = 'L';
                    a[i].x = m-2;
                }
                else {
                    a[i].x++;
                }
            }
        }
    }
    cout << ans2 << '\n';
    if (t == 3) {
        if (ans3[0].first == 0) {
            cout << 0;
            return 0;
        }
        cout << 1 << '\n';
        for (int i= 0 ; i < ans3.size(); ++i) {
            cout << ans3[i].first << ' ' << ans3[i].second << '\n';
        }
    }
}
