/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com)
 * Date: 2013.09.29
 */

#include <cstdio>

#include "random.h"

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

int main( int argc, char *argv[] )
{
  if (argc < 5)
  {
    puts("Usage: <seed for random> <n> <d> <c>");
    puts("  [seed == 0] => Time()");
    return 1;
  }

  int seed = atoi(argv[1]);
  int n = atoi(argv[2]);
  int d = atoi(argv[3]);
  int c = atoi(argv[4]);

  if (seed == 0)
    seed = Time(), fprintf(stderr, "seed = %d\n", seed);
  initrand(seed);

  printf("%d %d\n", n, d);
  int *a = new int[d];
  forn(i, n)
  {
    int good = 0;
    do
      forn(j, d)
        good |= (a[j] = R(-c, c));
    while (!good);
    forn(j, d)
      printf("%d%c", a[j], " \n"[j == d - 1]);
  }
  return 0;
}
