#include <bits/stdc++.h>
using namespace std;
char s1[100] = "";
char s2[100] = ".in";
int a[100010], mark[110];
bool y[100010];
void make(int n) {
memset(a, 0, sizeof(a));
memset(mark, 0, sizeof(mark));
memset(y, 0, sizeof(y));
int t = (int)floor(log2(n));
int lim = rand() % t + 1; // times
int lim2 = rand() % min(n, 1000) + 1; // count
for (int i = 0; i < lim; ++i) {
int p; // mark p 1
do {
p = rand() % t;
} while (mark[p]);
mark[p] = 1; // modified
int t = rand() % (lim2 >> 2) + 1;
if (t & 1) t ^= 1;
for (int j = 0; j < t; ++j) {
int pos;
do {
pos = rand() % (lim2 >> 2) + 1;
} while (a[pos] >> p & 1);
a[pos] |= 1 << p;
}
}
for (int i = 0; i < lim2; ++i) {
y[i] = true;
}
}
int main() {
srand(time(NULL));
int T = 10;
FILE *fp = NULL;
for (int i = 4; i < 5; ++i) {
s1[0] = i + '0';
s1[1] = '\0';
strcat(s1, s2);
fp = fopen(s1, "w");
fprintf(fp, "%d\n", T);
for (int t = 0; t < T; ++t) {
int op = rand() & 1;
if (op) {
int n = rand() % 10000 + 1;
fprintf(fp, "%d\n", n);
for (int j = 0; j < n; ++j) {
fprintf(fp, "%d ", rand() % 500 + 1);
}
}
else {
int n = rand() % 10000 + 1;
fprintf(fp, "%d\n", n);
make(n);
for (int j = 0; j < n; ++j) {
int t = rand() % 500 + 1;
if (y[j + 1]) t |= 1;
else if (t & 1) t ^= 1;
fprintf(fp, "%d ", t);
}
}
fprintf(fp, "\n");
}
}
return 0;
}