Time limit
1s
Memory limit
128 MB
Minhyuk and Youngsu are playing number baseball. Youngsu thinks of one three-digit number made from three distinct digits from 1 through 9. Minhyuk asks about three-digit numbers that satisfy the same condition, and Youngsu answers with the number of strikes and balls according to these rules.
Youngsu answered every question honestly, and the given answers do not contradict each other. Given all questions and answers so far, find how many numbers Youngsu could be thinking of.
The first line contains the number of questions, N. N is between 1 and 100, inclusive.
Each of the next N lines contains three values separated by spaces: the three-digit number Minhyuk asked about, the number of strikes in Youngsu's answer, and the number of balls in Youngsu's answer. Each asked number is made from three distinct digits from 1 through 9.
Print the number of three-digit numbers Youngsu could be thinking of.