Codeforces Round 796 (Div. 2)
C
Manipulating History
Codeforces
1700
原题
← BD →
翻译中…

As a human, she can erase history of its entirety. As a Bai Ze (Hakutaku), she can create history out of nothingness.—Perfect Memento in Strict Sense

翻译中…

Keine has the ability to manipulate history.

翻译中…

The history of Gensokyo is a string $s$ of length $1$ initially. To fix the chaos caused by Yukari, she needs to do the following operations $n$ times, for the $i$-th time:

翻译中…
  • She chooses a non-empty substring $t_{2i-1}$ of $s$.
  • She replaces $t_{2i-1}$ with a non-empty string, $t_{2i}$. Note that the lengths of strings $t_{2i-1}$ and $t_{2i}$ can be different.
翻译中…

Note that if $t_{2i-1}$ occurs more than once in $s$, exactly one of them will be replaced.

翻译中…

For example, let $s=$"marisa", $t_{2i-1}=$"a", and $t_{2i}=$"z". After the operation, $s$ becomes "mzrisa" or "marisz".

翻译中…

After $n$ operations, Keine got the final string and an operation sequence $t$ of length $2n$. Just as Keine thinks she has finished, Yukari appears again and shuffles the order of $t$. Worse still, Keine forgets the initial history.

翻译中…

Help Keine find the initial history of Gensokyo!

翻译中…

Recall that a substring is a sequence of consecutive characters of the string. For example, for string "abc" its substrings are: "ab", "c", "bc" and some others. But the following strings are not its substring: "ac", "cba", "acb".

翻译中…

Hacks

翻译中…

You cannot make hacks in this problem.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains a single integer $T$ ($1 \leq T \leq 10^3$) — the number of test cases. The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($1 \le n \lt 10 ^ 5$) — the number of operations.

翻译中…

The next $2n$ lines contains one non-empty string $t_{i}$ — the $i$-th string of the shuffled sequence $t$.

翻译中…

The next line contains one non-empty string $s$ — the final string.

翻译中…

It is guaranteed that the total length of given strings (including $t_i$ and $s$) over all test cases does not exceed $2 \cdot 10 ^ 5$. All given strings consist of lowercase English letters only.

翻译中…

It is guaranteed that the initial string exists. It can be shown that the initial string is unique.

翻译中…

Output

翻译中…

For each test case, print the initial string in one line.

翻译中…

Note

翻译中…

Test case 1:

翻译中…

Initially $s$ is "a".

翻译中…
  • In the first operation, Keine chooses "a", and replaces it with "ab". $s$ becomes "ab".
  • In the second operation, Keine chooses "b", and replaces it with "cd". $s$ becomes "acd".
翻译中…

So the final string is "acd", and $t=[$"a", "ab", "b", "cd"$]$ before being shuffled.

翻译中…

Test case 2:

翻译中…

Initially $s$ is "z".

翻译中…
  • In the first operation, Keine chooses "z", and replaces it with "aa". $s$ becomes "aa".
  • In the second operation, Keine chooses "a", and replaces it with "ran". $s$ becomes "aran".
  • In the third operation, Keine chooses "a", and replaces it with "yakumo". $s$ becomes "yakumoran".
翻译中…

So the final string is "yakumoran", and $t=[$"z", "aa", "a", "ran", "a", "yakumo"$]$ before being shuffled.

翻译中…

样例

Input #1
2
2
a
ab
b
cd
acd
3
z
a
a
aa
yakumo
ran
yakumoran
Output #1
a
z
InputCopy OutputCopy
题目信息
题号
1688C
时间限制
1 s
内存限制
256 MB
标签
构造
贪心
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。