#include <bits/stdc++.h>
#include "testlib.h"

using namespace std;
using ll = long long;

struct Limits {
    int T = 3;
    int n = 200'000;
    int m = 1'000'000'000;
    bool only_R = false;
    bool first_last_element = false;
};

const vector<Limits> LIMITS {
    /* 0 */ Limits{},
    /* 1 */ Limits{.T = 1},
    /* 2 */ Limits{.T = 2, .n = 3, .m = 4},
    /* 3 */ Limits{.n = 2, .first_last_element = true},
    /* 4 */ Limits{.n = 2, .m = 200'000},
    /* 5 */ Limits{.n = 2},
    /* 6 */ Limits{.T = 2, .n = 1000, .m = 1000},
    /* 7 */ Limits{.T = 2},
    /* 8 */ Limits{.only_R = true},
    /* 9 */ Limits{.n = 1000, .m = 1000},
    /* 10 */ Limits{}
};

int main(const int argc, char **argv) {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    registerValidation(argc, argv);

    const int group = atoi(validator.group().c_str());

    const auto limits = LIMITS[group];

    int T = inf.readInt(1, limits.T, "T");
    inf.readEoln();
    int n = inf.readInt(2, limits.n, "n");
    inf.readSpace();
    int m = inf.readInt(2, limits.m, "m");
    inf.readEoln();
    vector<int> a = inf.readInts(n, 1, m, "a");
    inf.readEoln();

    if (limits.first_last_element) {
        ensuref(a[0] == 1 && a[1] == m, "First element should be 1 and second should be m");
    }

    string s = inf.readToken("[LR]{" + to_string(n) + "}", "s");
    inf.readEoln();
    for (int i = 0; i < n; ++i) {
        ensuref(a[i] != 1 || s[i] != 'L', "if a[i] == 1, then s[i] != L");
        ensuref(a[i] != m || s[i] != 'R', "if a[i] == m, then s[i] != R");
    }

    if (limits.only_R) {
        for (int i = 0; i < n; ++i) {
            ensuref(s[i] == 'R', "all elements should be R");
        }
    }
    inf.readEof();
}
