Just a String

Time Limit: 2000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 3553
64-bit integer IO format: %I64d      Java class name: Main

Description

A substring of a string is a successive part of the string. Given a string your task is to find out the K-th alphabet order substring of the original string.
For example, the string "ABC" contains six substrings:
"A" "AB" "ABC" "B" "BC" "C" (in alphabet order)
and string "BBC" also contains six substrings:
"B" "B" "BB" "BBC" "BC" "C" (in alphabet order)

Input

The input contains several test cases, the first line of input contains the number of test cases.
For each test case, there is only one line contains the string S of length N, followed by a integer K. (1 <= K <= N*(N+1)/2, 1 <= N <= 100000, S contains only letters and digits)

Output

For each test cases, output the K-th alphabet order substring.

Sample Input

2
ABC 2
BBC 3

Sample Output

Case 1: AB
Case 2: BB

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .