Is Date Possible?
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
Imti has two lists, each containing single-digit numbers. He wants to know if itβs possible to create all the dates from 01 to 31 using these two lists. Here's how he forms a date:
He picks one digit from the first list.
He picks one digit from the second list.
He combines the two digits (first digit followed by the second digit) to form a two-digit number.
For example:
If the first list is [0, 1, 2] and the second list is [1, 2, 3], Imti can form dates like 01, 12, and 23.
However, he cannot form a date like 04 because 4 is not in either list.
Can Imti use the digits in these two lists to form all dates from 01 to 31?
Input
The first line T, (1<=T <=1000)- number of test case.
In each test case contains following line:
The first line contains two integers, π and π ( 1 β€ π , π β€ \(10^5\) ) representing the sizes of the two lists.
The second line contains π integers, the elements of the first list π ( 0 β€ π β€ 9 )
The second line contains π integers, the elements of the first list π ( 0 β€ π β€ 9 )
Sum of N over all test cases doesn't exceed \(10^5\).
Sum of M over all test cases doesn't exceed \(10^5\).
Output
In each test case, print "YES" if it's possible to form all dates from 01 to 31, otherwise print "NO".
Sample
Input | Output |
---|---|
|
|
Happy New Year 2025
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 8
- Start at
- 2025-01-02 14:30
- End at
- 2025-01-02 17:00
- Duration
- 2.5 hour(s)
- Host
- Partic.
- 117