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

#include <cstdio>
#include <vector>

#include "random.h"

using namespace std;

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

typedef vector<int> vi;

int main( int argc, char *argv[] )
{
  if (argc != 8)
  {
    puts("Usage: <seed for random> <n> <d> <k> <coord> <koef> <max_coord>");
    puts("  [seed == 0] => Time()");
    puts("  generates n d-dimensional vectors in a basis of 2k fixed vectors");
    puts("  each vector is in one of k 2-dimensional bases");
    return 1;
  }

  int seed = atoi(argv[1]);
  int n = atoi(argv[2]);
  int d = atoi(argv[3]);
  int k = atoi(argv[4]);
  int coord = atoi(argv[5]);
  int koef = atoi(argv[6]);
  int max_c = atoi(argv[7]);

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

  vector <vi> v(2 * k, vi(d, 0));
  forn(i, 2 * k)
  {
    int good = 0;
    do
      forn(j, d)
        good |= (v[i][j] = R(-coord, coord));
    while (!good);
  }

  printf("%d %d\n", n, d);
  forn(_, n)
  {
    vi r;
    int good = 0, st = R(0, k - 1);
    do
    {
      r = vi(d, 0);
      forn(_i, 2)
      {
        int i = 2 * st + _i;
        int t = R(-koef, koef);
        forn(j, d)
          r[j] += v[i][j] * t;
      }
      forn(i, d)
        good |= r[i];
      forn(i, d)
        if (abs(r[i]) > max_c)
          good = 0;
    } while (!good);
    forn(i, d)
      printf("%d%c", r[i], " \n"[i == d - 1]);
  }
  return 0;
}
