/***
 * Usage: n, p0, p1, k, [srand_seed]
 *
 * p0 - 0..200000 - number of 0-s
 * p1 - 0..200000 - number of 1-s
 * p0 + p1 <= 1000
 * k - max number
 ***/

#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

unsigned R()
{
  return rand() + (rand() << 15);
}

__int64 Time()
{
  _asm rdtsc
}

#define maxn 200000

int a[maxn];

int main( int argc, char *argv[] )
{
  int i, n = atoi(argv[2]), p0 = atoi(argv[3]), p1 = atoi(argv[4]), k = atoi(argv[5]);
  int seed = atoi(argv[1]);

  srand(seed == -1 ? Time() : seed);
  printf("%d\n", n);
  for (i = 0; i < n; i++)
    a[i] = 2 + rand() % (k - 1);
  for (i = 0; i < p0; i++)
    a[i] = 0;
  for (i = 0; i < p1; i++)
    a[i + p0] = 1;
  random_shuffle(a, a + n);
  for (i = 0; i < n; i++)
    printf("%d%c", a[i], i == n - 1 ? '\n' : ' ');
  return 0;
}
