odd doctor 已更新

# NetEase Cloud Music

Time Limit
10s
Memory Limit
32768KB
Judge Program
Standard
Ratio(Solve/Submit)
12.50%(1/8)
Description:

Mr.Frog likes to use a music player called “NetEase Cloud Music”. There are N songs in the music library
of “NetEase Cloud Music”. We use the string Si to indicate the melody of the ith song. The duration of
the ith song is jSij seconds. The phoneme of the ith song at jth second(j 2 [1; jSij]) is Si;j . There are 26
types of phoneme, and we use lowercase ‘a’-‘z’ to represent them. Each phoneme appears at most once
in the same song.
Every day, Mr.Frog can choose exactly one song from the music library, then he will start playing this
song in the single tune circulation mode.
One day, he wants to listen a special melody “fabc”. If he chooses a song “abcdef”, he will listen the melody
“abcdefabcdefab... ...”. So, he can listen the special melody from 6th second to 9th second.
In the next Q days, Mr.Frog hopes to listen a special melody Mi at the ith day. Please tell him whether
he can listen this melody.

Input:

The first line contains an integer T, where T is the number of test cases. T test cases follow.
For each test case, the first line contains one integer N, where N is the number of songs in the music
library of “NetEase Cloud Music”.
The next N lines, the ith line contains one string Si, where Si is the melody of the ith song.
In the (N + 2)th line contains one integer Q.
The next Q lines, the ith line contains one string Mi, where Mi is the special melody that he wants to

listen at the ith day.

Output:

For each test case, output one line containing “Case #x:”, where x is the test case number (starting
from 1). The following Q lines, each line output “YES” if he can listen the special melody at the ith day.
Otherwise, output “NO”.

Sample Input:
1
4
abcd
acd
d
5
cda
ddddddd
cda
acdca
Sample Output:
Case #1:
YES
YES
YES
YES
NO
Hint:

For the 1st day, he chooses the 1st song from the music library, and plays this song in the single tunecirculation mode, he will listen the melody “abcdabcdabcdab... ...”. He can listen the special melody “cda”from 3rd second to 5th second.

Submit