SOLVE

LATER

TnP Thanksgiving Party

Problem

Editorial

Analytics

It has been a norm for the years that after getting placed everyone should throw a party for the tnp coordinators as a token of thanksgiving.

But Poster Jain and Pandey Ji has decided to change this norm. Instead they will give treats to all the placed ones in Dominos :D (Great na? coz they are the best :D ).

In Dominos each pizza is represented as a string of lowercase alphabets (ex : "**mantumania**").

**N** students are already placed. Now it's party time. Each **N** students has **N** preferred choices of pizza (not necessarily distinct).
Each student will like a pizza only if some prefix of his/her preferred pizza matches with the given pizza. (*ex : preferred pizza is : "mantumania" and given pizza is : "mantu" , So it matches and hence they like "mantu" pizza. )*

Poster Jain and Pandey Ji can go to Dominos for **Q** days. And they need to figure out whether on each day their ordered pizzas are satisfactory or not. i.e., if **M** pizzas are ordered on a particular day then atleast **S** pizzas among **M** are liked by the group (Particular pizza is liked by the group if it is liked by any of the **N** students). See sample test case for more clarification.

For **Q** days print "**Yes**" if the order is satisfactory else print "**No**".

**Input**

The first line contains an integer **N** *( 1 <= N <= 10^5 )*, number of students.

The second line contains **N** strings *( 1<= length of each string <= 10 )*, preferred pizza of each students.

The third line contains an integer **Q** *( 1 <= Q <= 100 )*, the no of days they can visit Dominos.

Each Day is represented by two lines

First line contains two integers **M** and **S** *( 1 <= S <= M <= 10^3 )*, no of pizzas ordered on a particular day and the no of pizzas need to be liked by the group respectively.

Second line contains **M** strings containing only lowercase english alphabets. *( 1 <= length of string <= 10 )* , pizzas ordered on the particular day.

**Output**

Print **Q** lines, each containing either "**Yes**" or "**No**".

**AUTHOR** : spaul100

5 mantumania pizzamania maniamania pizzapizza macaroni 2 5 4 mantu mania pizza abcd pi 5 5 abcdefghij aaaaaaaaaa bbcde pizza ab

Time Limit:
1.0 sec(s)
for each input file.

Memory Limit:
256 MB

Source Limit:
1024 KB

Marking Scheme:
Marks are awarded when all the testcases pass.

Allowed Languages:
C,
C++,
Clojure,
C#,
D,
Erlang,
F#,
Go,
Groovy,
Haskell,
Java,
Java 8,
JavaScript(Rhino),
JavaScript(Node.js),
Lisp,
Lisp (SBCL),
Lua,
Objective-C,
OCaml,
Octave,
Pascal,
Perl,
PHP,
Python,
Python 3,
R(RScript),
Racket,
Ruby,
Rust,
Scala 2.11.8,
Swift,
Visual Basic

Initializing Code Editor...

{"3a26bd9": "/pagelets/show-submission/algorithm/tnp-thanksgiving-party/", "3a26c3a": "/pagelets/recommended-problems/algorithm/tnp-thanksgiving-party/", "3a26c0f": "/pagelets/problem-author-tester/algorithm/tnp-thanksgiving-party/", "3a26c25": "/pagelets/problems-hint/algorithm/tnp-thanksgiving-party/", "3a26bf9": "/pagelets/suggested-problems/algorithm/tnp-thanksgiving-party/"}

{}

realtime.hackerearth.com

80

e943dee0004e1e40be91dab5e632a6accaec92fa

58a29e5cae2309f04b28

/realtime/pusher/auth/