TnP Thanksgiving Party
Practice
5 (1 votes)
Very Easy
Problem
3% Success 555 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
1 votes
Tags:
Very-Easy
Points:10
3 votes
Tags:
Very-Easy
Points:10
3 votes
Tags:
Very-Easy
Editorial

No editorial available for this problem.