﻿ Ningbo University of Technology Online Judge :: [1507] Kid Learns to Speak
• ### [1507] Kid Learns to Speak

• 时间限制: 2000 ms　内存限制: 65535 K
• 问题描述
• Kids always like imitate other people what they say. Although it maybe not correct.
But it does not matter, because kids don’t spell all letters at the beginning.
Now kids are learning speak words, and he or she will follow what father says.
Father should check if it is a subsequence of a string what kids say that father just says.
For example, "ace" is a subsequence of "adcbe" but not a subsequence of "bcae".
If he spell correctly, father will tell him "YES", otherwise "NO".

But I want to make it mysterious, so I will only tell you the first character of father's words and kid's words,
you should know it only by follows:
s0 = first character;
si = char((pos(S(i-1)) * multiplier + i * adder) % 26);
Where:
pos(a) = 0, pos(b) = 1, ....pos(z) = 25;

char(0)= a, char(1)= b, .....char(25)= z;

• 输入
• The first line will be an integer T (1 <= T <= 10) the number of test cases.
Each test case will start by a line containing 1 character and 3 integers (length, multiplier, adder) for the string what father says(1 <= length <= 10^7).
The next line will contain a single integer N(1 <= N <= 10^4).
The next N lines each contain 1 character and 3 integers (length, multiplier, adder) for the string what kid says(1 <= length <= 100).
All characters are lowercase character without blank space.
1 <= multiplier, adder <= 1000.
• 输出
• For each test, For each test case print a single line containing "Case n:" (without the quotes) where n is the test case number (starting from 1).
Then followed by N lines each containing either "YES" (without quotes) or "NO" (without quotes) otherwise.
• 样例输入
• 1
a 100 13 37
3
a 11 11 311
b 9 13 22
d 5 31 12

• 样例输出
• Case 1:
NO
NO
YES

• 提示
• It is difficult for newers.
• 来源
• Hungar
• 操作
﻿