logo AlgoBeat OnlineJudge
登录 注册

#216186. [ICPC 2019 NAIPC] Cutting Strings

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

题目描述

You are given a string and an integer . You can remove at most non-intersecting substrings from . Your task is to find the alphabetically (i.e., dictionary order) largest resulting string.

For example, with string abcdcada and , you can choose the substrings [abc]d[ca]da and remove them to get dda.

输入格式

Each input will begin with a line with a single integer (), which is the number of cases you must solve.

Each of the next lines will contain an integer and a string (, ), separated by a space.

The total length of all strings in the input will be at most .

输出格式

Output the largest string, alphabetically, that you can get by removing or fewer non-intersecting substrings from .

样例

样例输入 1

4
2 abcdcada
1 ababb
2 ababb
1 dadbdcdbdad

样例输出 1

dda
bb
bbb
ddcdbdad