#KEYENCE2021D. Choosing Up Sides

Choosing Up Sides

Score : 700700 points

Problem Statement

Let NN be a positive integer. Consider a competition where two teams, each with 2N12^{N-1} players, play against each other.

We have 2N2^N players numbered 11 through 2N2^N. Coach Snuke can do the following operation any number of times: separate the players into two teams A and B, each with 2N12^{N-1} players, and make them play against each other.

He wants to do this operation one or more times so that both of the following conditions are satisfied:

  1. there exists an integer nn such that, for every (i,j)(i, j) such that 1i<j2N1 \leq i < j \leq 2^N, Player ii and Player jj have belonged to the same team exactly nn times.
  2. there exists an integer mm such that, for every (i,j)(i, j) such that 1i<j2N1 \leq i < j \leq 2^N, Player ii and Player jj have belonged to different teams exactly mm times.

We can prove that there exist sequences of operations that achieve Snuke's objective. Among those sequences, present one sequence with the minimum possible number of operations.

Constraints

  • All values in input are integers.
  • 1N81 \leq N \leq 8

Input

Input is given from Standard Input in the following format:

NN

Output

Print a sequence of operations in the format below:

KK

s1s_1

s2s_2

\vdots

sKs_K

Here, KK represents the length of the sequence, and sis_i represents the division into teams in the ii-th operation. sis_i should be a string of length 2N2^N consisting of A and B. In the ii-th operation, if Player jj belongs to Team A, the j{j}-th character of sis_{i} should be A; if Player jj belongs to Team B, the j{j}-th character of sis_{i} should be B. Note that A and B each must occur exactly 2N12^{N-1} times in each sis_i.

Your output will be accepted when KK is the minimum possible length of a sequence of operations that achieves the objective, and the sequence actually achieves the objective.

1
1
AB
  • We can satisfy the objective with one operation.
  • Note that we must do at least one operation.