// Forza Ferrari!
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
    --x;
  }
  string s;
  cin >> s;
  bool good = true;
  vector<int> tm(n);
  for (int i = 0; i < n; i++) {
    tm[i] = s[i] == 'R' ? a[i] : m - 1 - a[i] + m - 1;
  }
  for (int i = 0; i < n; i++) {
    good &= tm[i] % 2 == tm[0] % 2;
  }
  cout << (good ? "Yes\n" : "No\n");
  if (good) {
    pair<int, vector<array<int, 2>>> answer = {INT_MIN, {}};
    for (int mask = 0; mask < (1 << 12); mask++) {
      vector<array<int, 2>> ans;
      int cur = m;
      vector<int> tm0 = tm;
      for (int t = 0; t < 12; t++) {
        if (mask >> t & 1) {
          int pos = 0;
          for (int i = 0; i < n; i++) {
            pos = max(pos, min(tm[i], 2 * (m - 1) - tm[i]) + 1);
          }
          ans.push_back({t, pos});
          cur = pos;
        }
        for (int i = 0; i < n; i++) {
          tm[i] = (tm[i] + 1) % (2 * (cur - 1));
        }
      }
      if (count(tm.begin(), tm.end(), tm[0]) == tm.size()) {
        answer = max(answer, {cur, ans});
      }
      tm = tm0;
    }
    if (T >= 2) {
      cout << answer.first << "\n";
    }
    if (T >= 3) {
      cout << answer.second.size() << "\n";
      for (auto &[x, y] : answer.second) {
        cout << x << " " << y << "\n";
      }
    }
  }
}
