Aurora has $$$n$$$ blocks. Each block has 6 sides, each side has a digit from $$$0$$$ to $$$9$$$ on it. The same digit on one block can appear multiple times.
Fairies taught Aurora some arithmetic and gave her a task — to build numbers with blocks. Aurora can choose any subset of blocks, rotate them any side up and arrange them in any order to get the target number. Naturally, Aurora builds a number with no leading zeros.
Now, Aurora needs to learn how to count. Fairies intend to ask her to build positive integers in the ascending order. Blocks used for one number can be reused for another number. Please help the fairies to determine the minimum number which Aurora will never be able to build using a given set of blocks.
The first line contains one integer $$$n$$$ — the number of blocks ($$$1 \le n \le 100\,000$$$).
Each of the next $$$n$$$ lines has 6 digits — $$$a_{i,1}, a_{i,2}, \ldots, a_{i,6}$$$ ($$$0 \le a_{i,j} \le 9$$$).
Output the minimal number which Aurora won't be able to build.
2 012345 098765
11
3 123456 789012 345678
90
5 111111 222222 333333 444444 555555
6