#include <cstdio>
#include <vector>

using namespace std;

typedef pair <int, int> pii;
typedef vector <int> vi;

#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fi first
#define mp make_pair
#define pb push_back
#define se second

/* following code I copied from collider problem. (file: collider/tests/random) */
int orandseed;
void osrand( int s ) { orandseed = s; }
int orand() { return ((orandseed = orandseed * 239017 + 301703) >> 8) & 0x7FFF; }
int r( int a, int b ) { return ((orand() << 16) | orand()) % (b - a + 1) + a; }

void shuffle( vi &v )
{
  forn (i, v.size())
    swap(v[i], v[r(0, i)]);
}

void outputTest( int rx, int ry, int v1, int v2, int n, int m, vector <pii> &lights, vector <vi> &on )
{
  printf("%d %d %d %d %d\n", ry, rx, v1, v2, n);
  forn (i, n)
    printf("%d %d\n", lights[i].fi, lights[i].se);
  printf("%d\n", m);
  forn (i, m)
  {
    printf("%d", on[i].size());
    forn (j, on[i].size())
      printf(" %d", on[i][j] + 1);
    puts("");
  }
  puts("");
}

void randomTest( int rx, int ry, int n, int m )
{
  int v1 = r(1, 20), v2 = r(1, 20);
  vector <pii> lights(n);
  forn (i, n)
    lights[i] = mp(r(1, rx - 1), r(1, ry - 1));
  vector <vi> on(m);
  forn (i, m)
  {
    forn (j, n)
      if (r(0, 1) == 0)
        on[i].pb(j);
    shuffle(on[i]);
  }
  outputTest(rx, ry, v1, v2, n, m, lights, on);
}

void maxTest()
{
  int rx = 50, ry = 50;
  int n = 15, m = 10000;
  vector <pii> lights(n);
  forn (i, n)
    lights[i] = mp(1 + (i % 8) / 2 * (rx - 7) / 4 + i % 2, 1 + (ry - 2) * (i / 8));
  vector <vi> on(m);
  forn (i, m)
  {
    forn (j, n)
      if (i % 2 == j % 2)
        on[i].pb(j);
    shuffle(on[i]);
  }
  outputTest(rx, ry, 1, 1, n, m, lights, on);
}

void maxTest2()
{
  int rx = 50, ry = 50;
  int n = 15, m = 10000;
  vector <pii> lights(n);
  forn (i, n)
    lights[i] = mp(1 + (i % 8) / 2 * (rx - 7) / 4 + i % 2, 1 + (ry - 3) * (i / 8) + r(0, 1));
  vector <vi> on(m);
  forn (i, m)
  {
    forn (j, n)
      if (i % 2 == j % 2)
        on[i].pb(j);
    shuffle(on[i]);
  }
  outputTest(rx, ry, 1, 1, n, m, lights, on);
}

int main()
{
  osrand(301703);
  randomTest(40, 50, 15, 10000);
  forn (i, 4)
    randomTest(10, 12, 3, 5);
  forn (i, 10)
    randomTest(5 * (i + 1), 5 * (i + 1) - r(0, 4), i + 3, 5 + i * 900);
  forn (i, 4)
    randomTest(50, 50, 15, 10000);
  maxTest();
  maxTest2();
  return 0;
}
