You are on page 1of 2

10/27/2019

CAKEWALK
You have one main string and some query strings.

You have to output the query strings which have at least k matches with the main string.

The number of matches between a query string and the main string is defined as the number of distinct characters
which are present in both of these strings.

If there is no such string: Print "No" (without the quotes) Otherwise: Print "Yes" (without the quotes) and then print all
the strings (each on a new line) which satisfy the condition, in the order in which they appear in input.

Note: All the strings are composed of lower-case alphabets.

Input Format

1.The first line contains one integer T - the number of test cases.

2.The first line of each test case contains one word - the main string.

3.The second line of each test case contains two integers, N and K.

4.The next N lines of each test case contain the query strings.

Constraints

1 <= T <= 10

1 <= N <= 100

1 <= K <= length(main string)

1 <= length(word) <= 100

Output Format

If no word has at least K matches, output "No" (without the " "). Else, print "Yes" along with list of strings with at
least K matches, each in a new line, in order they are given in input.

Sample Input 0

1
abc
3 2
aaabbb
abc
zzzzzz

Sample Output 0

Yes
aaabbb
abc

1/2
10/27/2019 0
Explanation

"aaabbb" and "abc" have more than 2 matches with "abc".

2/2

You might also like