The chocolate rooms

3.1

8 votes
Approved, Basic Programming, Basics of Implementation, Easy, Grammar-Verified, Implementation, Maps, Ready, Recruit, Sets
Problem

Your task is to take some chocolates from N different rooms. Each room contains Pi number of chocolates of the same or different brands. You are given an integer K.

Write a program to determine whether you can visit each room and find K different brands of chocolates.

Input format

  • First line: T denoting the number of test cases
  • For each test case:
    • First line: Two space-separated integers N and K
    • Next N lines: An integer P followed by P space-separated strings denoting the brands of the chocolates

Output format

For each test case, print Yes or No depending upon the result.

Constraints

1T5
1N102
1K103
1Pi102
1 Length of the strings 10

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

You can select two (K=2) distinct brands of chocolate. Therefore, 'Yes'.

Editor Image

?