Birthdate

3.2

12 votes
Easy
Problem

Statement

In the distant future, the IoT devices have taken over the earth and started living human-like lives. Interestingly, they are born just like humans(that is they have a birthdate!).

The truthful supercomputer Guru and the dumb thermostat Chela connect to each other after a very long time and the following conversation takes place between them:

  • Chela: Guru, I’m pleased to connect to you after so long! How’s everything?
  • Guru: Everything’s okay. You know what, I gave birth to M sub-computers
  • Chela: Oh! What are their ages?
  • Guru: You were born in January. The sum of their ages is equal to your birth date(day number of month). Since you know I love twisting problems into logical puzzles, I will give you K distinct multisets each of the form {A1, A2, …., Am} where one and only one of these K multisets will denote the actual ages of my sub-computers. Now, do you know the ages of my sub-computers?

Your task is to determine whether Chela knows the ages of the subcomputers after the above mentioned conversation had taken place.

Input

  • The first line of input contains an integer T denoting the number of test cases
  • The first line of each test case contains two space separated integers M, K - denoting the number of sub-computers of Guru and number of entries to be provided, respectively
  • Each of the following K lines contain M space separated integers of the form A1 A2 … Am denoting a possible multiset which may denote the ages of the sub-computers

Output

For each test case in a new line.

  • Output “YES” if Chela finally knows the ages of the subcomputers of Guru
  • Output “DEPENDS” if given information is insufficient to conclude whether Chela knows the ages of the subcomputers of Guru
  • Output “NO” if Chela still does not know the ages of the sub-computers of Guru

Note: Print without quotes. Quotes are shown only for clarity

Constraints

  • 1<=T<=1000
  • 1<=M<=5
  • 1<=K<=100
  • 1<=Ai<=31
  • No multiset in the input will be repeated
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Since it is given that one and only one of the multisets will be denoting actual ages, the answer must be {1, 2, 3}

Editor Image

?