logo AlgoBeat OnlineJudge
登录 注册

#213727. [NWRRC 2022] Hidden Digits

内存限制:512 MiB 时间限制:5000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given a sequence of digits , , . Find the minimum positive integer such that for all , the decimal representation of number contains the digit .

输入格式

Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.

The first line of each test case contains a single integer ().

The second line contains a string of digits ().

It is guaranteed that the sum of over all test cases does not exceed .

输出格式

For each test case, print a single integer --- the smallest positive integer such that the decimal representation of contains the digit for all .

样例

样例输入 1

6
5
12345
5
01234
3
239
9
998244353
10
1000000007
20
18446744073709551616

样例输出 1

1
10
92
45296
701
10367486