// ConsoleApplication4.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

struct sheep
{
    int pos;
    char dir;

    bool operator==(const sheep& oth) const = default;
    bool operator!=(const sheep& oth) const = default;
    constexpr bool operator<(const sheep& oth) const
    {
        return (pos < oth.pos) || (pos == oth.pos && dir < oth.dir);
    }

    void chdir(int m)
    {
        if (pos == m)
            dir = 'L';
        if (pos == 1)
            dir = 'R';
    }

    sheep move(int m) const
    {
        sheep s = *this;
        s.chdir(m);
        s.pos += (s.dir == 'L' ? -1 : 1);
        s.chdir(m);
        return s;
    }

    sheep after_move(int m, int k) const
    {
        long long p = pos + (dir == 'L' ? -1ll : 1ll) * k;
        bool good = p > 0;
        int mod = 2 * (m - 1);
        p %= mod;
        if (good && p <= 0)
            p += mod;
        char d = dir;
        if (p <= 1)
        {
            p = 2 - p;
            d = 'R';
        }
        if (p >= m)
        {
            p = 2 * m - p;
            d = 'L';
        }
        return sheep{ (int)p,d };
    }
};

struct timepoint
{
    union
    {
        ll first;
        ll tm;
    };
    union
    {
        int second;
        int pos;
    };
};

// {time, position}
timepoint solve(sheep a, sheep b, int m)
{
    if (a.pos > b.pos)
    {
        swap(a, b);
    }
    if (a.pos == b.pos)
    {
        return { 0,a.pos };
    }
    int tm = 0;
    if (a.dir == 'L')
    {
        int t = (a.pos - 1);
        a.pos = 1;
        if (b.dir == 'R')
            b.pos += t;
        else
            b.pos -= t;
        tm += t;
        a.dir = 'R';
        if (b.pos >= m)
        {
            b.pos = 2 * m - b.pos;
            b.dir = 'L';
        }
    }
    if (b.dir == 'R')
    {
        int t = (m - b.pos);
        a.pos += t;
        b.pos += t;
        b.dir = 'L';
        tm += t;
    }
    return { tm + (b.pos - a.pos) / 2,(a.pos + b.pos) / 2 };
}

timepoint solve2(sheep a, sheep b, int m)
{
    auto t = solve(a, b, m);
    if (t.first == 0 && a.dir == b.dir)
        t.second = m;
    return t;
}

timepoint solve3(sheep a, sheep b, int m)
{
    auto t = solve2(a, b, m);
    int t2 = m + 1 - t.second;
    if (t2 > t.second)
    {
        t.second = t2;
        t.first += (m - 1ll);
        // assert(false);
    }
    return t;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    // assert(t == 1);
    int n, m;
    cin >> n >> m;
    vector <int> a(n);
    for (auto& i : a)
    {
        cin >> i;
    }
    string s;
    cin >> s;
    int k = a[0] & 1;
    for (auto& i : a)
    {
        if ((i & 1) != k)
        {
            puts("No");
            return 0;
        }
    }
    cout << "Yes\n";
    if (t > 1)
    {
        vector <sheep> lst;
        for (size_t i = 0; i < n; i++)
        {
            lst.push_back(sheep{ a[i],s[i] });
        }
        sort(lst.begin(), lst.end());
        lst.resize(unique(lst.begin(), lst.end()) - lst.begin());
        n = lst.size();
        if (n == 1)
        {
            cout << m << '\n';
            if (t > 2)
                cout << "0\n";
        }
        else if (n == 2)
        {
            auto tmp = solve3(lst[0], lst[1], m);
            cout << tmp.pos << '\n';
            // assert(tmp.first > 0);
            if (t > 2)
            {
                if (tmp.pos != m)
                    cout << "1\n" << tmp.first << ' ' << tmp.second << '\n';
                else
                    cout << "0\n";
            }
        }
        else
        {
            /*vector <int> mns;
            for (size_t i = 0; i < n; i++)
            {
                for (size_t j = i + 1; j < n; j++)
                {
                    mns.push_back(solve2(lst[i], lst[j], m).pos);
                }
            }
            sort(mns.begin(), mns.end());
            int x = mns[0];
            int y = m - x + 1;
            if (x < y)
                x = y;
            for (auto& i : mns)
            {
                if (i == x)
                    i = y;
            }
            cout << *min_element(mns.begin(), mns.end()) << '\n';*/
            /*assert(count(s.begin(), s.end(), 'L') == 0);
            int tm = 0;
            int cm = m;
            vector <pair<int, int>> opers;
            while (lst.size() > 1)
            {
                sheep a = lst.back();
                lst.pop_back();
                sheep b = lst.back();
                auto res = solve3(a, b, cm);
                tm = res.first;
                int lm = res.second;
                if (lm < cm)
                {
                    opers.emplace_back(tm, lm);
                    cm = lm;
                }
            }
            cout << lst.back().pos + tm << '\n';
            if (t > 2)
            {
                cout << opers.size() << '\n';
                for (auto& i : opers)
                {
                    cout << i.first << ' ' << i.second << '\n';
                }
            }*/
            // assert(n <= 3);
            //assert(m <= 4);
            /*assert(t == 2);
            int best = m;
            for (size_t i = 0; i < n; i++)
            {
                for (size_t j = i + 1; j < n; j++)
                {
                    timepoint tp = solve3(lst[i], lst[j], m);
                    best = min(best, tp.second);
                }
            }
            cout << best << '\n';*/
            set<sheep> cur(lst.begin(), lst.end());
            int tm = 0;
            int cm = m;
            vector <pair<int, int>> opers;
            while (cur.size() > 2)
            {
                int lm = 1;
                for (auto& i : cur)
                {
                    lm = max(lm, i.pos);
                }
                /*int lm2 = cm - lm + 1;
                if (lm < lm2)
                {
                    tm += (cm - 1);
                    set<sheep> cur2;
                    for (auto& i : cur)
                    {
                        sheep s = i;
                        for (size_t j = 1; j < cm; j++)
                        {
                            s = s.move(cm);
                        }
                        cur2.insert(s);
                    }
                    swap(cur, cur2);
                    continue;
                }*/
                if (lm < cm)
                {
                    opers.emplace_back(tm, lm);
                    cm = lm;
                }
                tm++;
                set<sheep> cur2;
                for (auto& i : cur)
                {
                    cur2.insert(i.after_move(cm, 1));
                }
                swap(cur, cur2);
            }
            if (cur.size() == 2)
            {
                auto res = solve3(*cur.begin(), *next(cur.begin()), cm);
                res.first += tm;
                if (res.second < cm)
                {
                    opers.emplace_back(res.first, res.second);
                    cm = res.second;
                }
            }
            cout << cm << '\n';
            if (t > 2)
            {
                cout << opers.size() << '\n';
                for (auto& i : opers)
                {
                    cout << i.first << ' ' << i.second << '\n';
                }
            }
        }
    }
    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
