String queries - MarisaOJ: Marisa Online Judge

String queries

Time limit: 1000 ms
Memory limit: 256 MB
Given $n$ strings consisting only of lowercase letters, each string having a length of at most $5$. You are given $q$ queries, where each query is a string. Determine whether each query string exists among the initial $n$ strings. ### Input - The first line contains the integer $n$. - The next $n$ lines each contain a string. - The following line contains the integer $q$. - The next $q$ lines each contain a string, representing a query. ### Output - For each query, if the string exists among the initial $n$ strings, print `YES`; otherwise, print `NO`. ### Constraints - $1 \le n,q \le 10^6$. - Each string consists only of lowercase letters. ### Example Input: ``` 2 marisa reimu 4 marisa rei reimu mio ``` Output: ``` YES NO YES NO ```