Congruent Numbers

Given the two legs of a right triangle as fractions p1/q1 and p2/q2, print 1 if the triangle's area is an integer, otherwise 0.

Easy2MathNumber theoryImplementationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

A congruent number is an integer that is the area of some right triangle whose sides all have rational length. In this problem you only look at the two legs of the right triangle, not the hypotenuse.

A rational number is a fraction p/qp/q where the numerator pp and the denominator qq are both integers. If q=1q = 1, then p/1p/1 is an integer, so every integer is a rational number.

You are given the rational lengths of the two legs of a right triangle. Determine whether the area of that triangle is a congruent number. In this problem the hypotenuse does not have to be rational.

Input

The input consists of a single test case. Your program may be run several times on different inputs.

The first line contains four integers p1p_1, q1q_1, p2p_2, q2q_2 (1p1,q1,p2,q21000001 \le p_1, q_1, p_2, q_2 \le 100000). The numbers p1/q1p_1/q_1 and p2/q2p_2/q_2 are the lengths of the two legs of the right triangle.

Output

Print 11 on a single line if the area of the triangle is an integer, and 00 otherwise. A rational area is not enough; it has to be an integer.