

A = 2
B = 4
The answer should be D = 2 [gcd of (2,4)] and X = 1 and Y = 0 (|X+Y|=1 is the minimum possible value that can be obtained here).
The first line contains a single integer ‘T’ representing the number of test cases. Then each test case follows.
The first line of every test case contains two integers ‘A’ and ‘B’ denoting the 2 coefficients.
For each test case, print three integers ‘D’, ‘X’, and ‘Y’ where ‘D’ is the gcd of ‘A’ and ‘B’ and ‘X’ and ‘Y’ are the two coefficients that satisfy the equation AX + BY = D.
The output of each test case should be printed in a separate line.
You are not required to print anything, it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= A <= 10^9
1 <= B <= 10^9
Time Limit = 1 sec
Use the Euclidean algorithm to find the gcd of A and B first and then use the extended euclidean algorithm to find the coefficients of the equation.
More about Euclidean algorithm - https://cp-algorithms.com/algebra/euclid-algorithm.html