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

using namespace std;

#define len(a) int(a.size())
#define all(a) a.begin(), a.end()

class Parser {
public:
    Parser() {}
    Parser(int argc, char* argv[]) {
        for (int i = 0; i < argc; ++i) {
            string t = argv[i];
            if (t.find('=') != string::npos) {
                int pos = t.find('=');
                _value[t.substr(0, pos)] = t.substr(pos + 1);
            }
        }
    }

    string get_string(string s, string def = "") {
        if (!_value.count(s)) {
            return def;
        }
        return _value[s];
    }

    long long get(string s, long long def = -1) {
        if (!_value.count(s))
            return def;
        return stoll(_value[s]);
    }

private:
    map<string, string> _value;
};

template<typename T>
void print_vector(vector<T> a) {
    for (int i = 0; i < (int) a.size(); ++i) {
        cout << a[i];
        if (i + 1 != a.size())
            cout << ' ';
    }
    cout << '\n';
}

Parser parser;

vector<int> select_k(int n, int k) {
    vector<int> p(n);
    iota(all(p), 0);
    shuffle(all(p));
    p.resize(k);
    return p;
}

struct dsu {
    vector<int> p;

    dsu(int n) {
        p.resize(n);
        iota(all(p), 0);
    }

    int get(int v) {
        if (v == p[v]) return v;
        return p[v] = get(p[v]);
    }

    void merge(int a, int b) {
        a = get(a);
        b = get(b);
        p[a] = b;
    }
};

void gen_eq(vector<int> &a, int cnt_eq) {
    vector<pair<int, int>> abobus;
    int n = len(a);
    dsu d(n);
    for (int i = 0; i < cnt_eq; ++i) {
        int i1 = rnd.next(0, n - 1);
        int i2 = rnd.next(0, n - 1);
        d.merge(i1, i2);
    }
    for (int i = 0; i < n; ++i) {
        a[i] = a[d.get(i)];
    }
}

int main(int argc, char* argv[]) {
    registerGen(argc, argv, 1);
    parser = Parser(argc, argv);

    string type = parser.get_string("type");
    if (type == "group3") {
        int m = parser.get("m");
        int T = parser.get("T");
        cout << T << '\n';
        cout << 2 << ' ' << m << '\n';
        cout << 1 << ' ' << m << '\n';
        cout << "RL\n";
        return 0;
    }

    int T = parser.get("T");
    int n = parser.get("n", 0);
    int m = parser.get("m");
    int even = parser.get("even");
    int cnt = parser.get("cnt", 0);
    int cnt_eq = parser.get("cnt_eq", 0);

    cout << T << '\n';
    if (type != "mult_ans_full" && type != "mult_ans_1000") {
        cout << n << ' ' << m << '\n';
    }
    vector<int> a(n);
    string s(n, 'R');
    if (type == "rand") {
        // 1 <= a[i] * 2 + even <= m
        // even == 1: 0 <= a[i] <= down (m - 1) / 2
        // even == 0: 1 <= a[i] <= m / 2
        if (even == 1) {
            for (int i = 0; i < n; ++i) {
                a[i] = 2 * rnd.next(0, (m - 1) / 2) + 1;
            }
        } else {
            for (int i = 0; i < n; ++i) {
                a[i] = 2 * rnd.next(1, m / 2);
            }
        }
        auto z = select_k(n, cnt);
        for (int &i : z) {
            a[i] ^= 1;
            if (a[i] == 0) ++a[i];
            if (a[i] == m + 1) --a[i];
        }
        gen_eq(a, cnt_eq);
        for (int i = 0; i < n; ++i) {
            if (rnd.next(1, 2) == 1) s[i] = 'L';
            else s[i] = 'R';

            if (a[i] == 1 && s[i] == 'L') s[i] = 'R';
            if (a[i] == m && s[i] == 'R') s[i] = 'L';
        }
        print_vector(a);
        cout << s << '\n';
    } else if (type == "R-rand") {
        if (even == 1) {
            for (int i = 0; i < n; ++i) {
                a[i] = 2 * rnd.next(0, (m - 2) / 2) + 1;
            }
        } else {
            for (int i = 0; i < n; ++i) {
                a[i] = 2 * rnd.next(1, (m - 1) / 2);
            }
        }
        auto z = select_k(n, cnt);
        for (int &i : z) {
            a[i] ^= 1;
            if (a[i] == 0) ++i;
            if (a[i] == m) --i;
        }
        for (int i = 0; i < n; ++i) {
            s[i] = 'R';
        }
        gen_eq(a, cnt_eq);
        print_vector(a);
        cout << s << '\n';
    } else if (type == "max_answer") {
        a = vector<int>(n, rnd.next(1, m - 3));
        for (int i = 0; i < n; ++i) {
            s[i] = 'R';
        }
        int i = rnd.next(0, n - 1);
        a[i] += 2;
        if (a[i] == m) s[i] = 'L';
        print_vector(a);
        cout << s << '\n';
    } else if (type == "zero_diff") {
        a = vector<int>(n, rnd.next(1, m - 1));
        for (int i = 0; i < n; ++i) {
            s[i] = 'R';
        }
        print_vector(a);
        cout << s << '\n';
    } else if (type == "mult_ans_full") {
        // n >= 8
        m = 1'000'000'000;
        auto upd_pos = [&](int i, int pos) {
            if (pos < m - 1) {
                s[i] = 'R';
                a[i] = pos + 1;
            } else {
                s[i] = 'L';
                a[i] = 2 * m - 1 - pos;
            }
        };

        for (int n = 200'000; n > 0; --n) {
            if ((2 * m - 2) % n == 0 && ((2 * m - 2) / n) % 2 == 0) {
                vector<int> pos(n);
                a.resize(n);
                s.resize(n, 'a');
                for (int j = 0; j < n; ++j) pos[j] = 1ll * j * (2 * m - 2) / n;
                cout << n << ' ' << m << '\n';
                shuffle(all(pos));
                for (int j = 0; j < n; ++j) upd_pos(j, pos[j]);
                print_vector(a);
                cout << s << '\n';
                return 0;
            }
        }
    } else if (type == "mult_ans_1000") {
        m = 1'000;
        auto upd_pos = [&](int i, int pos) {
            if (pos < m - 1) {
                s[i] = 'R';
                a[i] = pos + 1;
            } else {
                s[i] = 'L';
                a[i] = 2 * m - 1 - pos;
            }
        };

        for (int n = 1'000; n > 0; --n) {
            if ((2 * m - 2) % n == 0 && ((2 * m - 2) / n) % 2 == 0) {
                vector<int> pos(n);
                a.resize(n);
                s.resize(n, 'a');
                for (int j = 0; j < n; ++j) pos[j] = 1ll * j * (2 * m - 2) / n;
                cout << n << ' ' << m << '\n';
                shuffle(all(pos));
                for (int j = 0; j < n; ++j) upd_pos(j, pos[j]);
                print_vector(a);
                cout << s << '\n';
                return 0;
            }
        }
    } else {
        exit(1);
    }
}
