LearnPy Hub
← Arena
IntermediateRating 1300

Where Schedules Overlap

Each of two people has a sorted list of non-overlapping closed intervals. Print every interval where both are busy, in order. Print NONE if there are none.

Input

n and m; n lines for the first person; m lines for the second.

Output

Lines 'l r' or NONE.

Sample 1

Input
4 4
0 2
5 10
13 23
24 25
1 5
8 12
15 24
25 26
Output
1 2
5 5
8 10
15 23
24 24
25 25

Sample 2

Input
1 1
1 3
5 9
Output
NONE
solution.py
Output appears here
Where Schedules Overlap · Python Arena problem · LearnPy Hub