#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;
    vector<int> a(n);
    for (auto& i : a) cin >> i;
    string s;
    cin >> s;
    int best = -1;
    vector<pair<int, int>> ns;
    function<void(vector<int>, string, int, int, vector<pair<int, int>>)> gen = [&](vector<int> pos, string rot, int gr, int depth, vector<pair<int,int>> ans) {
        if (depth > 15) {
            return;
        }
        int mx = *max_element(pos.begin(), pos.end());
        if (mx < gr) {
            ans.emplace_back(depth, gr - 1);
            gen(pos, rot, gr - 1, depth, ans);
        }
        for (int i = 0; i < n; i++) {
            if (pos[i] == 1) rot[i] = 'R';
            if (pos[i] == gr) rot[i] = 'L';
        }
        bool check = true;
        for (int i = 0; i < n; i++) {
            check &= rot[i] == rot[0];
            check &= pos[i] == pos[0];
        }
        if (check) {
            if (best < gr) {
                best = gr;
                ns = ans;
            }
        }
        for (int i = 0; i < n; i++) {
            if (rot[i] == 'R') pos[i]++;
            else pos[i]--;
        }
        gen(pos, rot, gr, depth + 1, ans);
    };
    vector<pair<int, int>> buf;
    gen(a, s, m, 0, buf);
    if (best == -1) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    if (t >= 2) {
        cout << best << '\n';
    }
    if (t >= 3) {
        cout << ns.size() << '\n';
        for (auto& [i,j] : ns) {
            cout << i << ' ' << j << '\n';
        }
    }
}