#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

const int MOD = 1e9 + 7;
const int Inf = 2e9;
const ll INF = 3e18;

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  int n, m;
  cin >> n >> m;
  vector <int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  if (s[0] != s[1] && a[0] % 2 != a[1] % 2) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    int fir, sec;
    if (s[0] != s[1]) {
      fir = (a[0] + a[1]) / 2;
      sec = m - fir + 1;
    } else {
      fir = abs(a[0] - a[1]);
      sec = m - fir + 1;
    }
    if (T >= 2) {
      cout << max(fir, sec) << '\n';
    }
    int t = 0;
    while (a[0] != max(fir, sec) || a[1] != max(fir, sec)) {
      if (s[0] == 'R') a[0]++;
      else a[0]--;
      if (s[1] == 'R') a[1]++;
      else a[1]--;
      if (a[0] == m+1) {
        a[0] = m-1;
        s[0] = 'L';
      } else if (a[0] == 0) {
        a[0] = 2;
        s[0] = 'R';
      }
      if (a[1] == m+1) {
        a[1] = m-1;
        s[1] = 'L';
      } else if (a[1] == 0) {
        a[1] = 2;
        s[1] = 'R';
      }
      t++;
    }
    if (T == 3) {
      cout << "1\n";
      cout << t << ' ' << max(fir, sec) << '\n';
    }
  }
  return 0;
}