#K436. Subsequence Query Checker

    ID: 27345 Type: Default 1000ms 256MiB

Subsequence Query Checker

Subsequence Query Checker

In this problem, you are given a main string ( s ) and several query strings. For each query string ( t ), you need to determine whether ( t ) is a subsequence of ( s ). A string ( t ) is a subsequence of ( s ) if there exists a sequence of indices ( 1 \le i_1 < i_2 < \cdots < i_{|t|} \le |s| ) such that ( s[i_j] = t[j] ) for all ( j ).

For example, if ( s = \texttt{abcde} ), then ( \texttt{ace} ) is a subsequence of ( s ) (since we can pick characters at positions 1, 3, and 5), while ( \texttt{aec} ) is not.

You are required to answer multiple queries and output "YES" if the query string is a subsequence of ( s ) and "NO" otherwise. All input and output operations should be handled via stdin and stdout.

inputFormat

The input is given via standard input in the following format:

( s ) (string): The main string.

( n ) (integer): The number of queries.

Next ( n ) lines: Each line contains a query string ( t_i ) (which can be an empty string).

outputFormat

For each query, output a single line containing "YES" if the query string is a subsequence of ( s ) and "NO" otherwise.## sample

abcde
3
abc
ace
aec
YES

YES NO

</p>