Alumni X61143


Statement
 

pdf   zip

At UPF there is a document with the names of all students that finished their studies, but an employee opened the wrong document in the UPF servers and accidentally deployed the Alumni virus.

The virus reads all student names and merges them into a single string that maintains the order of each name. For instance, Alumni can read alice and bob and generate a document with a single string alibobce. Both alice and bob are subsequences of this string, but another name such as bond is not. Multiple names can share letters in the generated string, e.g. Alumni can merge boben and bobby as bobebny.

UPF needs your help to write a program that determines whether or not a student name is part of a string dd and reports “YES” or “NO” accordingly.

Input

The input starts with the number of test cases T100T \leq 100. For each test case, there is an intenger Q100Q \leq 100 that represents the number of queries to answer. The following line is the output non-empty string dd of Alumni virus with less than 10610^6 characters. The next QQ lines are strings that correspond to possible non-empty student names, and their length could be as large as min(|d|,1000)min( |d|, 1000 ). Your program should say if each student name exists in dd. All input strings have lowercase letters.

Output

For each test case, output QQ lines corresponding to each query: “YES” if the queried name exist, “NO” otherwise. Print and end of line character after each test case.

Public test cases
  • Input

    2
    3
    alibobce
    alice
    bob
    bond
    3
    bobebny
    boben
    bone
    bobby
    

    Output

    YES
    YES
    NO
    
    YES
    NO
    YES
    
    
  • Information
    Author
    Javier Segovia
    Language
    English
    Official solutions
    C++
    User solutions
    C++