2268. Pass

单点时限: 2.0 sec

内存限制: 256 MB

Nico is organizing a programming contest. It is a single contest, and registration is not required. Contestants log in to the system with a username and password. Because registration is not required, each contestant gets the username “userN”. However, Nico wants the contestants are not to be able to guess their passwords (so that they can log in as a different user). On the other hand, completely random passwords are bad too, as they look cryptic and the contestants might have problems typing them in.

Nico decides to generate random indices into a pool of syllables instead. Your task is to generate the passwords, given the syllable pool and the indices into it.

Given a set of syllables and a sequence of indices into it, generate the password by concatenating the corresponding syllables.

输入格式

The first line contains the number of scenarios.

Every scenario consists of a single line containing the number of syllables 1 <= m <= 50, followed by m lines, each containing a single syllable. Syllables consist of at most 5 characters and do not contain spaces. The number of passwords 1 <= n <= 200 follows on a single line, followed by n lines containing the indices of each password. Each of the lines contains the number of indices 1 <= k <= 10 of its password, followed by k indices. Indices are guaranteed to be in the interval [0,…,m-1].

输出格式

The output for every scenario begins with a line containing “Scenario #i:”, where i is the number of the scenario counting from 1.

Then, print each generated password on a single line.

样例

Input
2
4
an
bar
doh
mu
2
4 0 0 0 0
2 3 1
2
a
r
1
10 0 1 1 1 1 1 1 1 1 1
Output
Scenario #1:
anananan
mubar
Scenario #2:
arrrrrrrrr

9 人解决,10 人已尝试。

9 份提交通过,共有 20 份提交。

5.4 EMB 奖励。

创建: 16 年,3 月前.

修改: 7 年,2 月前.

最后提交: 6 年,1 月前.

来源: TUD Programming Contest 2008 (Training Session), Darmstadt, Germ

题目标签