Given two opposite corners of an axis-aligned square, construct the other two corners or report that it is impossible.
Problem
You are given the coordinates of two distinct points in the plane. Your task is to determine whether these points can be two vertices of an axis-aligned square.
If they can, output the coordinates of the other two vertices of such a square. If multiple answers are possible, any valid one is accepted.
If the two given points cannot be two vertices of an axis-aligned square, output -1.
Notes
- The square's sides must be parallel to the coordinate axes.
- The two given points may be adjacent vertices or opposite vertices only if they can be part of such a square.
- Coordinates are integers.
Input Format
Two lines, each containing two integers and — the coordinates of the given points.
Output Format
If it is possible to form an axis-aligned square, print two lines with the coordinates of the remaining two vertices. Otherwise, print -1.
Constraints
- The two given points are distinct.
- Coordinates are integers.
- Use integer arithmetic only.
Example 1
Input
0 0 0 1
Output
1 0 1 1
Explanation
The given points are the left side of a unit square. The other two vertices are at x = 1.
Example 2
Input
0 0 1 1
Output
-1
Explanation
These points cannot be two vertices of an axis-aligned square.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.