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

using namespace std;

const int MIN_N = 1;
const int MAX_N = 3000;
const int MIN_K = 1;
const int MAX_K = 10000;
const int MIN_F = 1;
const int MAX_F = 3000;

const int rnd_test_n = 100;

template <typename T> void append(vector<T> &dest, const vector<T> &orig) {
	dest.insert(dest.end(), orig.begin(), orig.end());
}

string output_tc(int n, int k, const vector<pair<string, int>> &meds) {
	ostringstream oss;
    oss << n << " " << k << endl;
    for (int i = 0; i < n; i++) {
        oss << meds[i].first << " " << meds[i].second << endl;
    }
	return oss.str();
}

vector<string> generate_sample_tests() {
	vector<string> tests;
    tests.push_back(output_tc(2, 5, {{"Paracetamol", 180}, {"Amoxicilina", 300}}));
	return tests;
}

vector<string> generate_manual_tests() {
	vector<string> tests;
	tests.push_back(output_tc(5, 10, {{"a", 1},{"b", 1},{"c", 1},{"d", 1},{"e", 1}}));
	return tests;
}

string rnd_test(int i){
    int min_n = MIN_N;
    int max_n = MAX_N;
    
    if(i<rnd_test_n / 3){
        max_n = 100;
    }
    else if(i<rnd_test_n / 2){
        max_n = 1000;
    }

    int n = rnd.next(min_n, max_n);
    int k = rnd.next(MIN_K, MAX_K);

    vector<pair<string, int>> meds(n);
    for (int i = 0; i < n; i++) {
        meds[i].first = rnd.next("[a-zA-Z]{1,15}");
        meds[i].second = rnd.next(MIN_F, MAX_F);
    }

    return(output_tc(n, k, meds));
}

vector<string> generate_random_tests() { 
    vector<string> tests;
    for (int i = 0; i < rnd_test_n; i++){
        tests.push_back(rnd_test(i));
    }
    return tests;
}

string extreme_test_1(){
    int n = MAX_N;
    int k = MAX_K;
    vector<pair<string, int>> meds(n);
    for (int i = 0; i < n; i++) {
        meds[i].first = rnd.next("[a-zA-Z]{1,15}");
        meds[i].second = MAX_F;
    }
    return(output_tc(n, k, meds));
}

vector<string> generate_extreme_tests(){
    vector<string> tests;   
    tests.push_back(extreme_test_1());
    return tests;
}

int main(int argc, char *argv[]) {
	registerGen(argc, argv, 1);
	vector<string> tests;
	size_t test = 0;
	append(tests, generate_sample_tests());
	append(tests, generate_manual_tests());
	append(tests, generate_random_tests());
	append(tests, generate_extreme_tests());
	for (const auto &t : tests) {
		startTest(++test);
		cout << t;
	}
	return 0;
}