#include<bits/stdc++.h>

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    int T;
    std::cin >> T;
    int n, m;
    std::cin >> n >> m;
    --m;
    std::vector<int> a(n);
    for (auto& i : a) std::cin >> i, --i;
    std::string s;
    std::cin >> s;
    std::vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') b[i] = a[i];
        else b[i] = m + (m - a[i]);
    }
    std::sort(b.begin(), b.end());
    for (int i = 0; i < 2 * n; ++i) b.push_back(b[i] + 2 * m);
    std::vector<int> vec(n);
    for (int i = 0; i < n; ++i) {
        if ((b[i + 1] - b[i]) % 2 == 0) {
            std::cout << "No\n";
            return 0;
        }
        vec[i] = (b[i + 1] - b[i]) / 2;
    }
    std::cout << "Yes\n";
    if (T >= 2) {
        std::cout << m + 1 - (std::accumulate(vec.begin(), vec.end(), 0) - *std::max_element(vec.begin(), vec.end())) << '\n';
        if (T >= 3) {
            int k = (std::max_element(vec.begin(), vec.end()) - vec.begin() + 1) % n;
            long long cur = 0;
            std::vector<std::pair<long long, int>> ans;
            for (int i = 0; i < n - 1; ++i) {
                if (vec[(k + i) % n] == 0) continue;
                long long need = (m - vec[(k + i) % n] - b[k] % (2 * m) + 2 * m) % (2 * m);
                long long dt = (need - cur % (2 * m) + 2 * m) % (2 * m);
                cur += dt;
                // assert((b[k] + cur) % (2 * m) == m - 1);
                m -= vec[(k + i) % n];
                ans.emplace_back(cur, m + 1);
            }
            std::cout << ans.size() << '\n';
            for (auto [x, y] : ans) std::cout << x << ' ' << y << '\n';
        }
    }
}