All submissions for this problem are available.
Chef has a very important String written but due to an accident the String gets shredded into its composing letters and divided into two parts s1 and s2. Thankfully, the order of the letters has not changed, and the Chef has a few guesses as to what the string can be. Help Chef decide if his guess for S can be composed out of s1 and s2 or not.
For example, if Chef had string "Greetings" it could get shredded into "Geeng" and "rtis" but the characters in s1 and s2 will be in the same order as S.
Note: A blank line indicates Chef's guess is an empty string.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a two space separated strings s1 and s2 followed by single integer N denoting the number of guess by the Chef
The next N lines contain a single guess S.
For each test case, output a N lines containing YES if the guessed string could be the possible initial string, and NO otherwise
For subtask 1:
- 1 ≤ T ≤ 1
- 1 ≤ N ≤ 10
- 0 ≤ |s|,|s1|,|s2| ≤ 10
For subtask 2:
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 1000
- 0 ≤ |s|,|s1|,|s2| ≤ 1000
Input: 1 tsec codecell 3 tseccodecell codetseccell codecell Output: YES YES NO
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.