#712
Unrated
Transforming Pairs
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Answer QQ (1Q1051\le Q\le 10^5) independent queries each of the following form:

You are given four integers a,b,c,da,b,c,d (1018a,b,c,d1018-10^{18}\le a,b,c,d\le 10^{18}). In one operation you can either do a+=ba\mathrel{+}=b, or b+=ab\mathrel{+}=a. Determine the minimum number of operations to transform (a,b)(a,b) into (c,d)(c,d), or if it is impossible to do so, output 1-1.

입력

The first line contains QQ.

The next QQ lines each contain four integers a,b,c,da,b,c,d.

출력

The answer for each query on a separate line.

예제 입력 1

4
5 -3 -1 -3
5 3 5 2
5 3 8 19
5 3 5 3

예제 출력 1

2
-1
3
0

점수

Input 2: a,b,c,d10|a|, |b|, |c|,|d|\le 10Input 3: a,b0a,b\ge 0Input 4: a0ba \geq 0 \geq bInput 5: a0ba \leq 0 \leq bInput 6: a,b0a,b\le 0Input 7: c,d0c,d\ge 0Input 8: c0dc \geq 0 \geq dInput 9: c0dc \leq 0 \leq dInput 10: c,d0c,d\le 0Inputs 11-14: Q103Q \leq 10^3Inputs 15-19: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.