Transforming Pairs
시간 제한2초메모리 제한2048 MB
두 정수와 두 목표가 주어질 때 a+=b 또는 b+=a 연산만으로 최소 연산 횟수를 구하거나 불가능을 판별한다.
문제
Answer () independent queries each of the following form:
You are given four integers (). In one operation you can either do , or . Determine the minimum number of operations to transform into , or if it is impossible to do so, output .
입력
The first line contains .
The next lines each contain four integers .
출력
The answer for each query on a separate line.