Not Alone in 2024
Time limit1sMemory limit1024 MB
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.
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 , , , are the homes of Jaewoo, Jaehyeon, the woman Jaewoo likes, and the woman Jaehyeon likes, in that order.
- and contain the MatKor intersection.

- The value of is , and the value of is .

- 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 and of and , respectively, and then come together.

Dongwoo thought about it for a while and said the following.
Then is .
Jaewoo and Jaehyeon were very surprised, since it seemed Dongwoo knew which woman each of them liked. Use and to find .
Assume that all points lie on a plane, and that distance means straight-line distance. If two points coincide, their distance is .
Input
The first line contains two integers and , separated by a space.
Output
Print , 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 and cannot occur on a plane, print -1.
If more than one value of is possible, print -2.