You would have been fed up with competitive programming questions so far, now it is time to solve little math.

Assume you have a equation A * x - B * y = 0

For a given value of A and B, find the minimum positive integer value of x and y that satisfies this equation.


First line contains T, number of test cases 0 <= T <=1000 followed by T lines.

First line of each test case contains two space seperated integers A and B. 1 <= A, B <=1 000 000 000.


For each test case, output a single line containing two integers x and y (seperated by a single space).


2 3

3 2


  • Brute force won't pass the given constraint.
  • Negative number cases are avoided to make the problem easy.

hide comments
looser69: 2017-04-08 09:28:06

easy !! accepted in one go!!!use gcd

rohit9934: 2017-03-11 15:56:15

when a==b values of x and y are "1 1". i was putting 1.this give me 6 WA. Nice and easy.1 line of logic.

da_201501181: 2017-03-06 14:52:04

AC in one GO...!! Very Simple..!!

scorpion_ajay: 2017-02-16 13:14:52

too easy :)
AC in a go...!

the_phoenixx: 2017-01-27 12:13:37

Easy question!!
just think simple!!
AC in one go!!

sanjanajain: 2017-01-25 15:39:23

m getting WA plz check my code @http://ideone.com/xFuXzT

swatantragupta: 2016-12-24 18:02:17

Easiest question till now!!!

aayushsinha44: 2016-12-22 17:32:47

think gcd of a and b

mishra_sharad: 2016-08-20 10:47:46

really simple as logic is one liner....

subhs_7: 2016-08-14 10:26:17

Last edit: 2016-08-14 10:39:02

Added by:B.R.ARVIND
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64