Status:  Past  Start:  20141004 12:30:00  End:  20141004 16:30:00 
The 2014 ACMICPC Caribbean National Contests (Real contest)
Problem
2950  Cows & Bulls
Created by  Orlenys López Pintado 
Added by  kko (20140611) 
Limits 
Total Time: 20000 MS

Test Time:
2000 MS
Memory: 62 MB  Output: 64 MB  Size:
14 KB

Enabled languages  
Available in 
Description
“Cows and bulls” is a very popular twoplayer game among Cuban students. Each player begins by secretly forming a four digit number without leading zeros and using exactly four distinct digits. The goal of the game is to guess the opponent's hidden number. The players take turns. In her turn, a player will write down a number and the opponent will count how many cows and bulls the guessed number contain. A bull is a digit found in the opponent's number that is placed at the same position. Similarly, a cow is a digit contained in the secret number but at another place. The player who guesses the opponent's number first wins the game.
Little Kenny is tired of losing to his big brother Kevin. Given the sequence of moves already played by Kevin, he needs you to write a program that computes the numbers he must choose in order to win.
Because Kenny and Kevin are both children, they added a simplifying rule: cows and bulls will be revealed after each round.
Little Kenny is tired of losing to his big brother Kevin. Given the sequence of moves already played by Kevin, he needs you to write a program that computes the numbers he must choose in order to win.
Because Kenny and Kevin are both children, they added a simplifying rule: cows and bulls will be revealed after each round.
“Cows and bulls” is a very popular twoplayer game among Cuban students. Each player begins by secretly forming a four digit number without leading zeros and using exactly four distinct digits. The goal of the game is to guess the opponent's hidden number. The players take turns. In her turn, a player will write down a number and the opponent will count how many cows and bulls the guessed number contain. A bull is a digit found in the opponent's number that is placed at the same position. Similarly, a cow is a digit contained in the secret number but at another place. The player who guesses the opponent's number first wins the game.
Little Kenny is tired of losing to his big brother Kevin. Given the sequence of moves already played by Kevin, he needs you to write a program that computes the numbers he must choose in order to win.
Because Kenny and Kevin are both children, they added a simplifying rule: cows and bulls will be revealed after each round.
Little Kenny is tired of losing to his big brother Kevin. Given the sequence of moves already played by Kevin, he needs you to write a program that computes the numbers he must choose in order to win.
Because Kenny and Kevin are both children, they added a simplifying rule: cows and bulls will be revealed after each round.
“Cows and bulls” is a very popular twoplayer game among Cuban students. Each player begins by secretly forming a four digit number without leading zeros and using exactly four distinct digits. The goal of the game is to guess the opponent's hidden number. The players take turns. In her turn, a player will write down a number and the opponent will count how many cows and bulls the guessed number contain. A bull is a digit found in the opponent's number that is placed at the same position. Similarly, a cow is a digit contained in the secret number but at another place. The player who guesses the opponent's number first wins the game.
Little Kenny is tired of losing to his big brother Kevin. Given the sequence of moves already played by Kevin, he needs you to write a program that computes the numbers he must choose in order to win.
Because Kenny and Kevin are both children, they added a simplifying rule: cows and bulls will be revealed after each round.
Little Kenny is tired of losing to his big brother Kevin. Given the sequence of moves already played by Kevin, he needs you to write a program that computes the numbers he must choose in order to win.
Because Kenny and Kevin are both children, they added a simplifying rule: cows and bulls will be revealed after each round.
Input specification
Line 1: An integer N (1 <= N <= 7) indicating the number of rounds already played by Kenny.
Lines 2 … N + 1: Each line will contain the information of a round. A round is described by a four digit number (without leading zeros and comprising four different digits). Then, there will be two integers C and B, the number of cows and bulls, respectively. C digits will follow and then B other digits.
Lines 2 … N + 1: Each line will contain the information of a round. A round is described by a four digit number (without leading zeros and comprising four different digits). Then, there will be two integers C and B, the number of cows and bulls, respectively. C digits will follow and then B other digits.
Line 1: An integer N (1 <= N <= 7) indicating the number of rounds already played by Kenny.
Lines 2 … N + 1: Each line will contain the information of a round. A round is described by a four digit number (without leading zeros and comprising four different digits). Then, there will be two integers C and B, the number of cows and bulls, respectively. C digits will follow and then B other digits.
Lines 2 … N + 1: Each line will contain the information of a round. A round is described by a four digit number (without leading zeros and comprising four different digits). Then, there will be two integers C and B, the number of cows and bulls, respectively. C digits will follow and then B other digits.
Line 1: An integer N (1 <= N <= 7) indicating the number of rounds already played by Kenny.
Lines 2 … N + 1: Each line will contain the information of a round. A round is described by a four digit number (without leading zeros and comprising four different digits). Then, there will be two integers C and B, the number of cows and bulls, respectively. C digits will follow and then B other digits.
Lines 2 … N + 1: Each line will contain the information of a round. A round is described by a four digit number (without leading zeros and comprising four different digits). Then, there will be two integers C and B, the number of cows and bulls, respectively. C digits will follow and then B other digits.
Output specification
Write a line for each possible number Kenny may guess, taking into consideration all the information his opponent has given him. These numbers must be printed in increasing order.
Write a line for each possible number Kenny may guess, taking into consideration all the information his opponent has given him. These numbers must be printed in increasing order.
Line 1: An integer N (1 <= N <= 7) indicating the number of rounds already played by Kenny.
Lines 2 … N + 1: Each line will contain the information of a round. A round is described by a four digit number (without leading zeros and comprising four different digits). Then, there will be two integers C and B, the number of cows and bulls, respectively. C digits will follow and then B other digits.
Lines 2 … N + 1: Each line will contain the information of a round. A round is described by a four digit number (without leading zeros and comprising four different digits). Then, there will be two integers C and B, the number of cows and bulls, respectively. C digits will follow and then B other digits.
Sample input
2
2345 0 3 2 4 5
1654 2 0 4 5
Sample output
2045
2745
2845
2945