| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 1024 MB | 34 | 9 | 4 | 66.667% |
You are given a sequence of $n$ digits $d_0,ドル $d_1,ドル \dots $d_{n - 1}$. Find the minimum positive integer $x$ such that for all 0ドル \le i < n,ドル the decimal representation of number $x + i$ contains the digit $d_i$.
Each test contains multiple test cases. The first line contains the number of test cases $t$ (1ドル \le t \le 10^5$). The description of the test cases follows.
The first line of each test case contains a single integer $n$ (1ドル \le n \le 10^6$).
The second line contains a string of $n$ digits $d_0 d_1 \ldots d_{n-1}$ (0ドル \le d_i \le 9$).
It is guaranteed that the sum of $n$ over all test cases does not exceed 10ドル^6$.
For each test case, print a single integer $x$ --- the smallest positive integer such that the decimal representation of $x+i$ contains the digit $d_i$ for all 0ドル \le i < n$.
6 5 12345 5 01234 3 239 9 998244353 10 1000000007 20 18446744073709551616
1 10 92 45296 701 10367486