#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <vector>

using namespace std;

const int max_val = 100 * 1000;
const int max_size = 100 * 1000;

int cnt[4];
vector <int> color[4];

int rand_num()
{
    return (rand() * 32000 + rand());
}

int main(int argc, char ** argv)
{
    int i, j, num, col, rb, lb, n;

    //freopen("style.in", "w", stdout);

    cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;

    n = argc;

    //return n;

    srand(atoi(argv[1]));

    for (i = 0; i < n / 4; i++)
    {
        num = atoi(argv[i * 4 + 2]);
        col = atoi(argv[i * 4 + 3]);
        lb = atoi(argv[i * 4 + 4]);
        rb = atoi(argv[i * 4 + 5]);
        cnt[col] += num;
        for (j = 0; j < num; j++)
            color[col].push_back(rand_num()%(rb - lb + 1) + lb);
    }
    for (i = 0; i < 4; i++)
    {
        if (cnt[i] == 0)
        {
            cnt[i] = 1;
            color[i].push_back(rand_num() % max_val + 1);
        }
        if (cnt[i] > max_size)
            cnt[i] = max_size;
        printf("%d\n", cnt[i]);
        random_shuffle(color[i].begin(), color[i].end());
        for (j = 0; j < cnt[i] - 1; j++)
            printf("%d ", color[i][j]);
        printf("%d", color[i][j]);
        printf("\n");
    }

    return 0;
}

