F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

AB String

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 325    Accepted Submission(s): 125


Problem Description
Given a string $S$ contains only $A$ and $B$.

Calculate the Kth string $T$ which doesn't appear in $S$.

Compare the string in order of length,if length is same,then sort in order of lexicographical order.
 

Input
First line contains a single integer $cases (cases \leq 5)$ which denotes the number of test cases.

For each test case, the first line is string $S (1 \leq |S| \leq 20000)$, the second line have $T+1$ numbers,the first number is $T$,next $T$ number(s) is Kth. $(1 \leq T \leq 10, 1 \leq K \leq 10^9)$
 

Output
For each case, output $T$ lines.
 

Sample Input
2 A 1 1 AAABBA 1 1
 

Sample Output
B ABA
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-10 05:47:40, Gzip enabled