#include "testlib.h"
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const double pi = acos(-1.0);


int main(int argc, char ** argv) {
	registerGen(argc, argv, 1);
	if (argc != 5) {
		cerr << "Usage: n, k, isStrict, seed" << endl;

		return 1;
	}

	int n = atoi(argv[1]);
	int k = atoi(argv[2]);
	int f = atoi(argv[3]);
	ensuref(f >= 0 && f <= 1, "invalid flag");
	if (!f) {
		n = rnd.next(1, n);
		k = rnd.next(0, min(n, k));
	}

	vector <int> a(n, 0);
	vector <int> p(n);
	for (int i = 0; i < n; i++)
		p[i] = i;
	shuffle(p.begin(), p.end());
	for (int i = 0; i < k; i++)
		a[p[i]] = rnd.next(0, p[i]);	

	cout << n << endl;
	for (int i = 0; i < n; i++)
		cout << a[i] << " \n"[i == n - 1];

    return 0;
}