#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

set <int> first_line;
set <pair <int, int> > cells;

int main(int argc, char ** argv)
{
    int i, j, ps, px, py;
    int n = atoi(argv[1]);
    int m = atoi(argv[2]);
    int p = atoi(argv[3]);
    int k = atoi(argv[4]);
    srand(atoi(argv[5]));
    printf("%d %d %d %d\n", n, m, p, k);
    //fprintf(stderr, "here\n");
    for (i = 0; i < p; i++)
    {
        ps = rand() % m + 1;
        while (first_line.find(ps) != first_line.end())
            ps = rand() % m + 1;
        first_line.insert(ps);
    }
    //fprintf(stderr, "here\n");
    set <int> :: iterator it = first_line.begin();
    for ( ; it != first_line.end(); it++)
    {
        if (it != first_line.begin())
          printf(" ");
        //fprintf(stderr, "here\n");
        printf("%d", *it);
    }
    printf("\n");
    //fprintf(stderr, "here\n");
    for (i = 0; i < k; i++)
    {
        px = rand() % (n - 1) + 2;
        py = rand() % m + 1;
        while (cells.find(make_pair(px, py)) != cells.end())
        {
            px = rand() % (n - 1) + 2;
            py = rand() % m + 1;
        }
        cells.insert(make_pair(px, py));
    }
    set <pair <int, int> > :: iterator it2 = cells.begin();
    for ( ; it2 != cells.end(); it2++)
        printf("%d %d\n", (*it2).first, (*it2).second);

    return 0;
}
