问题3171--Pass

3171: Pass

[命题人 : ]
时间限制 : 1.000 sec  内存限制 : 64 MB

题目描述

Background 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. Problem 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.

样例输入 Copy

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

样例输出 Copy

Scenario #1:
anananan
mubar

Scenario #2:
arrrrrrrrr

来源/分类