Number Transformation
You are given two integers $$$x$$$ and $$$y$$$. You want to choose two strictly positive (greater than zero) integers $$$a$$$ and $$$b$$$, and then apply the following operation to $$$x$$$ exactly $$$a$$$ times: replace $$$x$$$ with $$$b \cdot x$$$.You want to find two positive integers $$$a$$$ and $$$b$$$ such that $$$x$$$ becomes equal to $$$y$$$ after this process. If there are multiple possible pairs, you can choose any of them. If there is no such pair, report it.For example:   if $$$x = 3$$$ and $$$y = 75$$$, you may choose $$$a = 2$$$ and $$$b = 5$$$, so that $$$x$$$ becomes equal to $$$3 \cdot 5 \cdot 5 = 75$$$;  if $$$x = 100$$$ and $$$y = 100$$$, you may choose $$$a = 3$$$ and $$$b = 1$$$, so that $$$x$$$ becomes equal to $$$100 \cdot 1 \cdot 1 \cdot 1 = 100$$$;  if $$$x = 42$$$ and $$$y = 13$$$, there is no answer since you cannot decrease $$$x$$$ with the given operations. 
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.Each test case consists of one line containing two integers $$$x$$$ and $$$y$$$ ($$$1 \le x, y \le 100$$$).
If it is possible to choose a pair of positive integers $$$a$$$ and $$$b$$$ so that $$$x$$$ becomes $$$y$$$ after the aforementioned process, print these two integers. The integers you print should be not less than $$$1$$$ and not greater than $$$10^9$$$ (it can be shown that if the answer exists, there is a pair of integers $$$a$$$ and $$$b$$$ meeting these constraints). If there are multiple such pairs, print any of them.If it is impossible to choose a pair of integers $$$a$$$ and $$$b$$$ so that $$$x$$$ becomes $$$y$$$, print the integer $$$0$$$ twice.
def BoogeyMan() -> None:
    """"""

    def cube_root(x):
        if x < 0:
            x = abs(x)
            cube_root = pow(x, 1 / 3) * -1
        else:
            cube_root = pow(x, 1 / 3)
        return cube_root

    def isCube(number: int) -> bool:
        cube_root = number ** (1.0 / 3.0)
        if round(cube_root) ** 3 == number:
            return True
        else:
            return False

    def isSquare(number: int) -> bool:
        root = math.sqrt(number)
        if int(root + 0.5) ** 2 == number:
            return True
        else:
            return False
    MOD = 100000.0
    for _ in range(ii()):
        (a, b) = mi()
        if b % a == 0 and a <= b:
            p(f'1 {b // a}')
        else:
            p('0 0')
if __name__ == '__main__':
    import os, sys, math, itertools, bisect
    from collections import deque, defaultdict, OrderedDict, Counter
    (ii, si) = (lambda : int(input()), lambda : input())
    (mi, msi) = (lambda : map(int, input().strip().split(' ')), lambda : map(str, input().strip().split(' ')))
    (li, lsi) = (lambda : list(mi()), lambda : list(msi()))
    (out, export, p, pp) = ([], lambda : print('\n'.join(map(str, out))), lambda x: out.append(x), lambda array: p(' '.join(map(str, array))))
    try:
        from baba_yaga import L, cmdIO, _generator_

        class _BoogeyMan_:

            def __init__(self) -> None:
                self.launchers = [cmdIO(), BoogeyMan(), export(), _generator_()]

            def init(self) -> None:
                for _ in self.launchers:
                    yield _
                    assert not _, 'EOF'

            def container(fun):

                def wrapper():
                    print(f'Success', end='\n')
                    fun()
                return wrapper

        @_BoogeyMan_.container
        def assembler():
            _BoogeyMan_().init()
        assembler()
    except (FileNotFoundError, ModuleNotFoundError):
        BoogeyMan()
        export()
class Solution:

    def __init__(self):
        pass

    def solve(self):
        t = int(input())
        result = []
        for i in range(t):
            (x, y) = map(int, input().split())
            if y % x == 0:
                result.append('{} {}'.format(1, y // x))
            else:
                result.append('0 0')
        for x in result:
            print(x)
if __name__ == '__main__':
    sol = Solution()
    sol.solve()
t = int(input())
s = ''
for _ in range(t):
    (x, y) = map(int, input().split())
    temp = str(y / x).split('.')
    if temp[1] == '0':
        s += '1 ' + temp[0] + '\n'
    else:
        s += '0 0\n'
print(s)