#include <stdio.h>
#include <stdlib.h>

void print_word(int w, int n)
{
	int i;

	for(i = n - 1; i >= 0; i--)
		printf("%c", 'a' + !!(w & (1 << i)));

	printf("\n");
}

int rules[8];

void main()
{
	int k, n, i;

	for(k = 1000; k > 0; k--)
	{
		n = 3 + rand() % 13;

		printf("%d\n", n);

		print_word(rand(), n);

		for(i = 0; i < 8; i++)
			rules[i] = (i << 1) | (rand() & 1);

		for(i = 0; i < 8; i++)
		{
			int t;

			int ai = rand() % 8;
			int bi = rand() % 8;

			t = rules[ai];
			rules[ai] = rules[bi];
			rules[bi] = t;
		}

		for(i = 0; i < 8; i++)
			print_word(rules[i], 4);

		printf("%d\n", rand() % 2000000001);
	}
}
