Bulls, Cows, and Digits

Limits 1s, 512 MB · Interactive

Let's play a game.

This game is a few centuries old. Nonetheless, it is a good one for an interactive problem.

This is the game of bulls and cows.

Cowboy Sherlock will guess a string with 4 digits in it. Each digit will be unique. You will have to guess what that string is.

Every time you guess, cowboy Sherlock will tell you the number of bulls and cows he sees. Don't fret, though. This is just Sherlock's way of giving you some hints.

The number of bulls implies the number of digits that you have guessed correctly, both in terms of the digits themselves and their positions. The number of cows implies the number of digits that you have guessed correctly, that they are present in the string, but not in the correct positions.

Confused? Here is an example:

Let's say Sherlock has guessed the string "7482". If you are to guess "4832", Sherlock will say "1 bull, 2 cows". Because, you have guessed that 4 and 8 are present in the string (but you didn't guess their correct positions), hence "2 cows". And, you have guessed that 2 is present in the string (along with its correct position: 4th digit), hence "1 bull".

You will get at most 100 chances to guess the correct string for each test case.

The game is simple, and cowboy Sherlock's patience is little. So, get coding!

Input

Every time you print a guess, you will receive two integers as input representing the number of bulls and cows. The numbers will always be between 0 and 4, and their sum will always be less than or equal to 4.

Output

Print your guess as a string with four digits followed by a newline character. Like so:

"0123\n"

Do not print anything after you have guessed the correct string (i.e. after you receive “4 0” as input).

Suppose the string that Sherlock has guessed is "5362". Here is what a possible interaction would look like:

< 0123
> 0 2
< 1045
> 0 1
< 2356
> 1 3
< 3652
> 1 3
< 5362
> 4 0

> indicates what your program reads and < indicates what your program writes. These symbols are here to make it easy to understand. You do not have to print such symbols from your program.

Your program prints "0123". As a result, your program will receive "0 2". This is because the digits 2 and 3 are present, but not in the correct position.

Your program then prints "1045". As a result, your program will receive "0 1". The digit 5 is present but not in the correct position.

Your program then prints "2356". As a result, your program will receive "1 3". All of the digits are present and 5 is now in the correct position.

Your program then prints "3652". As a result, your program will receive "1 3". All of the digits are present and 2 is now in the correct position.

Your program then prints "5362". As a result, your program will receive "4 0". All of the digits are present and are in the correct positions.

Your program should exit after it receives "4 0".

Printing a string with repeated digits will result in "Wrong Answer".