Under construction

Still being built. Things may change

Not Alone in 2024

Time limit1sMemory limit1024 MB

Summary
Given X = AC^2+BD^2 and Y = AB^2+CD^2 for segments AB and CD through the origin, output 2024 times MN^2 or -1 or -2.
Level

Medium6 of 10

Topics
Geometry, Math
Solved
No attempts yet

Problem

Jaewoo and Jaehyeon, who live on Mat Street, spend another lonely day in 2024. Dongwoo felt sorry for the two and arranged a 2-on-2 meeting with two female friends of his who also live on Kor Avenue. Mat Street runs horizontally and Kor Avenue runs vertically. The two streets meet at a right angle at the MatKor intersection, and each home is located exactly on Mat Street or Kor Avenue. A home may be exactly on the intersection.

After the first meeting, Jaewoo and Jaehyeon each liked a different one of the two women. Dongwoo asked many questions to find out who liked whom. As a result, Dongwoo learned the following, where AA, BB, CC, DD are the homes of Jaewoo, Jaehyeon, the woman Jaewoo likes, and the woman Jaehyeon likes, in that order.

  • AB‾\overline{AB} and CD‾\overline{CD} contain the MatKor intersection.

  • The value of AC‾2+BD‾2\overline{AC}^2+\overline{BD}^2 is XX, and the value of AB‾2+CD‾2\overline{AB}^2+\overline{CD}^2 is YY.

  • The MatKor intersection may be a home, and in that case it is also included in the segment. Two people may live in the same apartment, so two homes may be at the same position.

Jaewoo thought that the conditions are symmetric, so the woman he likes cannot be identified.

Jaehyeon bragged to Dongwoo that they would go on another double date together. The men would first meet at the midpoints MM and NN of AB‾\overline{AB} and CD‾\overline{CD}, respectively, and then come together.

Dongwoo thought about it for a while and said the following.

Then MN‾2\overline{MN}^2 is WW.

Jaewoo and Jaehyeon were very surprised, since it seemed Dongwoo knew which woman each of them liked. Use XX and YY to find WW.

Assume that all points lie on a plane, and that distance means straight-line distance. If two points coincide, their distance is 00.

Input

The first line contains two integers XX and YY, separated by a space. (1≤X,Y≤106)(1\le X, Y\le 10^{6})

Output

Print 2024⋅W2024\cdot W, since the year is 2024.

If the value above is not an integer, remove the fractional part and print only the integer part.

If Jaewoo lied and XX and YY cannot occur on a plane, print -1.

If more than one value of 2024⋅W2024\cdot W is possible, print -2.

Examples5

  1. Example 1

    Input
    20 32
    
    Expected output
    4048
    
  2. Example 2

    Input
    4 4
    
    Expected output
    2024
    
  3. Example 3

    Input
    4 8
    
    Expected output
    0
    
  4. Example 4

    Input
    3 9
    
    Expected output
    -1
    
  5. Example 5

    Input
    2023 2024
    
    Expected output
    1023132