#nt102. 扩展欧几里得

扩展欧几里得

Extended Euclidean Algorithm

Problem Description

Read TT, then TT test cases follow. Each case gives two numbers a,ba, b; output the minimal non-negative integer solution (x,y)(x, y) to ax−by=gcd⁡(a,b)a x - b y = \gcd(a, b).

Input Format

The first line contains one integer TT.

Each of the next TT lines contains two numbers a,ba, b.

Output Format

Output TT lines, each containing two numbers: xx and yy.

Sample Input

2
1 2
100 150

Sample Output

1 0
2 1

Constraints

For 100%100\% of the test cases, 1≤T≤1041 \le T \le 10^4 and 1≤a,b≤1091 \le a, b \le 10^9.