Skip to main content
Back to problems
Codeforces
Medium
Geometry
Arrays
Pashmak and Garden

Given two opposite corners of an axis-aligned square, construct the other two corners or report that it is impossible.

Acceptance 0%
Problem Statement

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 x1,y1x_1, y_1 and x2,y2x_2, y_2 — 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.
Examples
Sample cases returned by the problem API.

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.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.