N-orthotope
InterviewTime limit1sMemory limit256 MB
Given two axis-aligned boxes in N dimensions, print the dimension of their overlap, or -1 when they do not meet.
- Level
Easy1 of 10
- Topics
- Implementation, Geometry
- Solved
- No attempts yet
Problem
An axis parallel N-orthotope is the set of N dimensional points written in this form.
That is, it collects every point whose coordinate satisfies .
- For the set is defined as a point in 0 dimensions.
- For it is a segment on a line.
- For it is an axis parallel rectangular region in the plane.
- For it is an axis parallel rectangular box in space.
Generalize a little and allow in the product
If exactly indices satisfy , this set of points is an axis parallel N-orthotope. The words 'axis parallel' are dropped from here on, but every orthotope below is still axis parallel.
Two N-orthotopes are given for some . If some points belong to both regions at once, those points form an M-orthotope. Write a program that computes . For 2-orthotopes there are the four cases below.

- In A the common region is again a 2-orthotope.
- In B the common region is a 1-orthotope, a segment.
- In C the common region is a 0-orthotope, a point.
- In D there is no common region. Print -1 in that case.
Input
The first line has a natural number .
The second line has of the first region, separated by spaces.
The third line has of the second region, separated by spaces.
Every given number is an integer with absolute value at most 11, and holds for each .
.
Output
On the first line print if the common region of the two regions is an M-orthotope. If there is no common region, print -1.