N. Integer Perimeter
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

You are given six positive integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$, $$$e$$$ and $$$f$$$. You need to find out whether there exists a triangle $$$ABC$$$ with the following properties.

  • $$$AB/BC=a/b$$$;
  • $$$BC/CA=c/d$$$;
  • $$$CA/AB=e/f$$$;
  • Area of $$$ABC$$$ is positive;
  • The perimeter of the triangle is integer.

If such triangle exists, find the minimum possible value of its perimeter.

Input

The input consists of six lines, each containg one integer $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$, $$$e$$$ and $$$f$$$ ($$$1 \leq a, b, c, d, e, f \leq 1000$$$) respectively.

Output

If there is no triangle satisfying all the properties, print -1. Otherwise, print one integer — the minimum possible perimeter of such triangle.

Examples
Input
1
1
2
2
3
3
Output
1
Input
1
2
3
4
5
6
Output
-1
Input
1
2
2
3
3
1
Output
-1