×_7_9_2013 C: Anti-Virus

Problem C: Anti-Virus

Time Limit: 8 Sec   Memory Limit: 128 MB
Submit: 16   Solved: 2
[ Submit][ Status][ Web Board]

Description

Rocket323 is an engineer(ËT) in an anti-virus software company. One day, he discovered some signatures of a new virus. He wants to know whether his computer is infected with that virus or not? 

×_7_9_2013 C: Anti-Virus

In this problem, a computer program is a string consists of lowercase English letters. The signature of the new virus is also a string consist of lowercase English letters. The program is infected with the virus if the program consists of at least one signature.

Rocket323 is very curious, so you have to tell him how many signatures appeared in the program. Because the program is too long, it.s given to you in a compressed format. 

Input

There are multiple test cases. The first line consists of only a integer T (≤ 30) indicating the number of test cases.

For each test case:

The first line contains an integer N (0 < N ≤ 2000) indicating the number of signatures.

Then n lines follows, each represents a signature of the new virus. It.s guaranteed that the signatures only consist of lowercase English letters and each signature is not empty. The length of each signature is no more than 150 and these N strings are all different.

The last line of each test case is the computer program.
The program will be described in a compressed format. A compressed string consists of lowercase English

letters and /compressors0. A /compressor0is in the following format:

[qx]

q is a number(0 < q ≤ 109) and x is a lowercase English letter. It means q consecutive letter x(s) in the original uncompressed string. For example, [6k] means /kkkkkk0(without the quotes) in the original string. So, if a compressed string is like:

ab[2d]e[7k]g
It actually is 
/abddekkkkkkkg0(without the quotes) after decompressed to original format. The length of the compressed program is at least 1 and at most 106.
The length of the decompressed program is at most 5 
∗ 1014.
Note that the signature will never be given in the compressed format! 

Output

For each test case:
In the first line print string 
/Yes0(without the quotes) if the program is infected with the virus,

otherwise print /No0(without the quotes).
In the second line print the number of signature appeared in the program. Print 
/00(without the

quotes0) if the program is not infected with the virus. 

Sample Input

4 2 ab dcb dacb 3 a ab abc dabc 2 a ab [5a]b[4a]b 3 ab cd ef abcdef

Sample Output

No 0 Yes 3 Yes 2 Yes 3

聽說是ac自動機的模板 還沒有寫出來

你可能感兴趣的:(×_7_9_2013 C: Anti-Virus)