AT_abc459_g [ABC459G] Golf 2
Description
You are given integers $ A, B, X, Y $ .
A piece is placed on a two-dimensional plane. Initially, the piece is at coordinates $ (0, 0) $ .
You can perform the following operation zero or more times:
- Let $ (x, y) $ be the current coordinates of the piece. Move the piece to coordinates $ (x', y') $ satisfying one of the following conditions:
- $ |x - x'| = A $ and $ |y - y'| = B $
- $ |x - x'| = B $ and $ |y - y'| = A $
Determine whether it is possible to move the piece to coordinates $ (X, Y) $ , and if so, find the minimum number of operations required.
You are given $ T $ test cases; solve each.
Input Format
The input is given from Standard Input in the following format:
> $ T $ $ \text{case}_1 $ $ \text{case}_2 $ $ \vdots $ $ \text{case}_T $
The $ i $ -th $ (1 \le i \le T) $ test case $ \text{case}_i $ is given in the following format:
> $ A $ $ B $ $ X $ $ Y $
Output Format
Output the answers for the test cases in order, separated by newlines.
For each test case, if it is possible to move the piece to coordinates $ (X, Y) $ , output the minimum number of operations required; otherwise, output $ -1 $ .
Explanation/Hint
### Sample Explanation 1
Consider the first test case.
By moving the piece from $ (0, 0) $ to $ (1, 2) $ , then to $ (-1, 1) $ , then to $ (1, 0) $ in order, the piece can be moved to coordinates $ (1, 0) $ in three operations.
It is impossible to move the piece to coordinates $ (1, 0) $ in fewer than three operations, so output $ 3 $ on the first line.
### Constraints
- $ 1 \le T \le 2 \times 10^5 $
- $ 1 \le A < B \le 10^6 $
- $ 0 \le X, Y \le 10^6 $
- All input values are integers.