#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define int long long
#define ar(x) array<int, x>

using namespace std;

void sol() {
  int T;
  cin >> T;
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  set<int> kek;
  for (int &el : a) {
    cin >> el;
    --el;
    kek.insert(el % 2);
  }
  string s;
  cin >> s;
  if (kek.size() == 1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
    return;
  }
  if (T == 1) {
    return;
  }
  // vector<int> order(2 * m - 2);
  // for (int i = 1; i < m; ++i) {
    // order[i - 1] = i;
  // }
  // for (int i = 0; i < m - 1; ++i) {
    // order[(m - 1) + i] = m - i - 2;
  // }
  vector<int> mxnum_by_dist(2 * m);
  for (int i = 1; i < m - 1; ++i) {
    mxnum_by_dist[2 * i] = i;
    mxnum_by_dist[(m - 1 - i) * 2] = i;
  }
  vector<int> inds(n);
  for (int i = 0; i < n; ++i) {
    if (a[i] == 0) {
      inds[i] = 2 * m - 3;
    } else if (a[i] == m - 1) {
      inds[i] = m - 2;
    } else {
      if (s[i] == 'R') {
        inds[i] = a[i] - 1;
      } else {
        inds[i] = (m - 1) + (m - a[i] - 2);
      }
    }
    // assert(a[i] == order[inds[i]]);
  }
  int ans = m - 1;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int ind1 = inds[i], ind2 = inds[j];
      if (ind1 == ind2) {
        continue;
      }
      if (ind1 > ind2) {
        swap(ind1, ind2);
      }
      ans = min(ans, max(mxnum_by_dist[ind2 - ind1], mxnum_by_dist[2 * m - 2 - (ind2 - ind1)]));
    }
  }
  cout << ans + 1 << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  // cin >> t;
  while (t--) {
    sol();
  }
}


/*
3
2 3
1 3
RL


3
2 3
1 2
RL


3
3 5
1 3 5
RRL


2
3 5
1 3 5
RRL

2
10 19
1 3 5 7 9 11 13 15 17 19
LRLRLRLRLR
*/