You are playing an action video game. The game controller has buttons, `A`

, `B`

, `X`

, and `Y`

. In this game, you can get coins with combo moves. You can make a combo move by pressing buttons in sequence.

This game has a secret sequence of buttons, which can be represented as a string of those characters. You don't know the string , but you know its length .

**You also know that the first character of never reappears in it.** For example, can be `ABXYY`

or `XYYAA`

, but cannot be `AAAAA`

or `BXYBX`

.

You can press a sequence of up to buttons for a combo move. Let be the string which represents the sequence of the buttons you pressed. The number of coins you get for this move is calculated as the length of the longest prefix of which is also a substring of . A substring of a string is a contiguous (possibly empty) sequence of characters within . A prefix of is a substring of that is empty or contains the first character of .

For example, if is `ABXYY`

and is `XXYYABYABXAY`

, you will get coins because `ABX`

is the longest prefix of that is also a substring of .

Your task is to determine the secret string using few combo moves.

#### Implementation Details

You should implement the following function:

```
string guess_sequence(int N)
```

- : the length of .
- This function is called exactly once for each test case.
- This function should return the string .

Your program can call the following function:

```
int press(string p)
```

- : a sequence of buttons you press.
- must be a string of length between and , inclusive. Each character of must be
`A`

,`B`

,`X`

, or`Y`

. - You cannot call this function more than times for each test case.
- This function returns the number of coins you get when you press the sequence of buttons represented by p.

If some of the above conditions are not satisfied, your program is judged as `Wrong Answer`

. Otherwise, your program is judged as `Accepted`

and your score is calculated by the number of calls to `press`

(see Subtasks).

#### Example

Let be `ABXYY`

. The grader calls `guess_sequence(5)`

. An example of communication is shown below.

Call | Return |
---|---|

`press("XXYYABYABXAY")` |
3 |

`press("ABXYY")` |
5 |

`press("ABXYYABXYY")` |
5 |

`press("")` |
0 |

`press("X")` |
0 |

`press("BXYY")` |
0 |

`press("YYXBA")` |
1 |

`press("AY")` |
1 |

For the first call to press, `ABX`

appears in `XXYYABYABXAY`

as a substring but `ABXY`

does not, so is returned.

For the third call to press, `ABXYY`

itself appears in `ABXYYABXYY`

as a substring, so is returned.

For the sixth call to press, no prefix of `ABXYY`

but the empty string appears in `BXYY`

as a substring, so is returned.

Finally, `guess_sequence(5)`

should return `ABXYY`

.

The file `sample-01-in.txt`

in the zipped attachment package corresponds to this example.

#### Constraints

- Each character of the string is
`A`

,`B`

,`X`

, or`Y`

. - The first character of never reappears in .

In this problem, the grader is **NOT** adaptive. This means that is fixed at the beginning of the running of the grader and it does not depend on the queries asked by your solution.

#### Subtasks

(5 points)

(95 points) No additional constraints. For this subtask, your score for each test case is calculated as follows. Let be the number of calls to

`press`

.- If , your score is .
- If , your score is .
- If , your score is .
- If , your score is .
- Otherwise, your score is .

Note that your score for each subtask is the minimum of the scores for the test cases in the subtask.

#### Sample grader

The sample grader reads the input in the following format:

- line :

If your program is judged as `Accepted`

, the sample grader prints `Accepted: q`

with `q`

being the number of calls to the function press.

If your program is judged as `Wrong Answer`

, it prints `Wrong Answer: MSG`

. The meaning of `MSG`

is as follows:

`invalid press`

: A value of given to`press`

is invalid. Namely, the length of is not between and , inclusive, or some character of is not`A`

,`B`

,`X`

, or`Y`

.`too many moves`

: The function press is called more than times.`wrong guess`

: The return value of`guess_sequence`

is not .

## Comments

Is the problem statement (or checker) incorrect? It seems that making sure the number of calls to

`press`

is below`2N`

gets full AC yet it says for full points you have to get maximum`N + 2`

pressesEdit: Checker has been fixed

Java Grader?

IOI 18 supported java, will we have a Java grader for this question soon?

Empty??

I'm still working on it, hoping to have it done by October 14 or 15.

Problem statement and checker has been uploaded.