五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 1811A - Insert Digit

2023-06-13 14:25 作者:您是打尖兒還是住店呢  | 我要投稿

You have a positive number of length n

?and one additional digit.


You can insert this digit anywhere in the number, including at the beginning or at the end.


Your task is to make the result as large as possible.


For example, you have the number 76543

, and the additional digit is 4

. Then the maximum number you can get is 765443

, and it can be obtained in two ways — by inserting a digit after the 3

th or after the 4

th digit of the number.


Input

The first line contains a single integer t

?(1≤t≤104) — the number of test cases.

The descriptions of the test cases follow.

The first line of the description of each test case contains two integers n

?and d (1≤n≤2?105; 0≤d≤9) — the length of the number and an additional digit, respectively.

The second line of the description of each test case contains a string consisting of n

?digits — the number that you have initially. It is guaranteed that the number does not contain leading zeros.

It is guaranteed that the sum of n

?for all test cases does not exceed 2?105

.Output

For each test case, output a string consisting of n+1digits — the maximum possible number that can be obtained.

Example

input

11

5 4

76543

1 0

1

2 5

44

3 6

666

5 6

13579

5 8

97531

19 4

9876543210123456789

5 7

73737

8 1

20000000

7 0

7058959

12 1

828127127732

output

765443

10

544

6666

613579

987531

98765443210123456789

773737

210000000

70589590

8281271277321

找到第一個比給定字符小的數(shù),將這個數(shù)插入到此數(shù)之前即可當然如果都找不到那就放在最后面。

下面是代碼;


CF 1811A - Insert Digit的評論 (共 條)

分享到微博請遵守國家法律
西乌珠穆沁旗| 东兰县| 中江县| 黄大仙区| 灵台县| 桓仁| 北川| 和田市| 昌都县| 武定县| 石阡县| 德庆县| 青海省| 家居| 沙雅县| 开鲁县| 东乌| 文昌市| 射阳县| 尉犁县| 长寿区| 富阳市| 黔西县| 长武县| 彭山县| 克什克腾旗| 浦江县| 多伦县| 嫩江县| 美姑县| 错那县| 光泽县| 阿瓦提县| 金湖县| 三明市| 盐山县| 胶南市| 廊坊市| 奉化市| 东兴市| 荥经县|