Altimetrik Java Hiring Challenge | Milly and pens | Answer

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”.

Image result for program


  • 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 NP 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.


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


  • 1 ≤ T ≤ 10
  • 1 ≤ N ≤ 104
  • 1 ≤ P, M ≤ 105
  • 1 ≤ Pen id ≤ N

Sample Input
(Plaintext Link)

4 2 2
1 2
3 4
3 2 2
1 2
1 2

Sample Output
(Plaintext Link)

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