Milly and pens

3.6

507 votes
Implementation, Ready, Hash function, Easy, Data Structures
Problem

Milly and Pranjul together want to buy N unique pens. Each pen has a unique id. Pranjul can buy P pens and Milly can buy M pens at a time. Your task is to print “They can” if they can buy those N unique pens at least one each else print “They can’t”.

Input

  • First line of the input will contain T (No. of test cases).
  • For each test case, first line will contain three space separated integers denoting N, P and M. Then next line will contain P space separated integers denoting the ids of pen that Pranjul can buy and the next line will contain M space separated integers denoting the ids of pen that Milly can buy.

Output

  • For every test case, print the required answer in a new line.

Constraints

  • 1 ≤ T ≤ 10
  • 1 ≤ N ≤ 104
  • 1 ≤ P, M ≤ 105
  • 1 ≤ Pen idN
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Test case #2: Then can’t buy the pen with id = 3.

Editor Image

?