Home => ProblemSet => 6.1-02:扩展欧几里得
Problem1382--6.1-02:扩展欧几里得

1382: 6.1-02:扩展欧几里得

Time Limit: 1 Sec  Memory Limit: 128 MB  Submit: 0  Solved: 2
[ Submit ] [ Status ] [ Creator: ][ 参考程序 ]

Description

给定 n 对正整数 ai,bi,对于每对数,求出一组 xi,yi,使其满足 ai×xi+bi×yi=gcd(ai,bi)。

Input

第一行包含整数 n。
接下来 n 行,每行包含两个整数 ai,bi。

Output

输出共 n 行,对于每组 ai,bi,求出一组满足条件的 xi,yi,每组结果占一行。
本题答案不唯一,输出任意满足条件的 xi,yi 均可。

Sample Input Copy

2
4 6
8 18

Sample Output Copy

-1 1
-2 1

HINT

1≤n≤10^5,
1≤ai,bi≤2×10^9

Source/Category