Alice has a set of \(N\) unpleasant pairs of digits.
Consider a number bad if it satisfies the following conditions:
- Contains a pair of digits that goes in a row
- It is unpleasant
Otherwise, the number is considered good.
Your task is to determine \(K\) ascending good numbers.
Input format
- The first line contains one integer \(T\) that denotes the number of test cases.
- The first line of the test case contains two integers \(N\) and \(K\).
- The next \(N\) lines contain two digits \(d_1,d_2\).
Output format
Print \(T\) lines. The \(i^{th}\) line must contain an answer for the \(i^{th}\) test case.
Note: If answer is more than \(5\times10^{18}\), print -1.
Constraints
\(1≤ T≤ 1000 \)
\(0≤ n<100\)
\(0≤ d_1,d_2≤ 9\)
\(1≤ K≤ 10^{18}\)
The first 25 numbers that are good for the first test -> (1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,24,25,26,27)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor