欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2132A.Homework
Homework
Vlad and Dima have been assigned a task in school for their English class. They were given two strings and and asked to append all characters from to string in any order. The guys decided to divide the work between themselves and, after lengthy negotiations, determined who would add each character from string to .
Due to his peculiarities, Vlad can only add characters to the beginning of the word, while Dima can only add them to the end. They add characters in the order they appear in string . Your task is to determine what string Vlad and Dima will end up with.
Input
Each test consists of several test cases. The first line contains a single integer () — the number of test cases. The description of the test cases follows.
The first line contains an integer () — the length of the string .
The second line contains the string , consisting of lowercase letters of the English alphabet.
The third line contains an integer () — the length of the strings and .
The fourth line contains the string , consisting of lowercase letters of the English alphabet.
The fifth line contains the string , consisting of the characters 'V' and 'D' — the distribution of the characters of string between Dima and Vlad. If = 'V', then the -th letter is added by Vlad; otherwise, it is added by Dima.
Output
For each test case, output the string that will result from Dima and Vlad's work.
Note
In the first test case, there is initially a string . Then Dima appends the character to the end of the string, resulting in , and Vlad appends the last character, resulting in .
In the second test case, the string will change as follows: $efo \rightarrow efor \rightarrow defor \rightarrow deforc \rightarrow odeforc \rightarrow odeforce \rightarrow codeforce \rightarrow codeforces$
In the third test case: $aca \rightarrow acab \rightarrow bacab \rightarrow bacaba \rightarrow abacaba$
In the fourth test case: $biz \rightarrow abiz \rightarrow babiz \rightarrow babizo \rightarrow babizon$
Samples
4
2
ot
2
ad
DV
3
efo
7
rdcoecs
DVDVDVD
3
aca
4
bbaa
DVDV
3
biz
4
abon
VVDD
dota
codeforces
abacaba
babizon
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |