#K95682. Interval Intersection
Interval Intersection
Interval Intersection
Given two closed intervals \([a_1, b_1]\) and \([a_2, b_2]\), determine their intersection. Two intervals intersect if and only if \( \max(a_1, a_2) \leq \min(b_1, b_2) \). If they intersect, output the intersection as two numbers (start and end); otherwise, output "NO".
You need to process multiple test cases. In each test case, you are given four integers representing two intervals. For each case, print the intersection if it exists, or "NO" if it does not.
inputFormat
The input is given via standard input (stdin). The first line contains an integer \( t \) denoting the number of test cases. Each of the following \( t \) lines contains four space-separated integers: \( a_1\ b_1\ a_2\ b_2 \), representing the intervals \([a_1, b_1]\) and \([a_2, b_2]\).
outputFormat
For each test case, output the result on a separate line. If the intervals intersect, print the start and end of the intersection separated by a space. If they do not intersect, print "NO".
## sample4
1 5 2 6
1 2 3 4
5 7 1 6
2 5 5 10
2 5
NO
5 6
5 5
</p>