#include "testlib.h"

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)

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

    int MINN = opt<int>(1);
    int MAXN = opt<int>(2);
    int MAXVAL = opt<int>(3);
    int GOOD = opt<int>(4);

    int t = min(200'000 / MAXN, 10'000);
    println(t);

    forn(tt, t) {
        int n = rnd.next(MINN, MAXN);
        int m = rnd.next(1, n);
        if(!GOOD) m = 1;
        int val = rnd.next(0, MAXVAL);
        string s;
        println(n, m);
        if(rnd.next(0, 2) && GOOD){
            vector<int>parts = rnd.partition(m, n, 1);
            for(int i = 0; i < m; i++){
                for(int j = 0; j < parts[i] / 2; j++){
                    char c = char(rnd.next(0, val) + 'a');
                    s +=c; s+=c;
                }
                if(parts[i] % 2 != 0) s += char(rnd.next(0, val) + 'a');
            }
            shuffle(s.begin(), s.end());
        }
        else{
            for(int j = 0; j < n; j++){
                s += char(rnd.next(0, val) + 'a');
            }
        }
        println(s);
    }
}
