Greedy Gary and GCDs

Time limit: 2s Memory limit: 64MB Input: Output:

Task

Gary was in his math class learning about prime factorization, when his teacher gave him a problem: given two integers aa and bb, find their GCD (greatest common divisor), LCM (least common multiple), and product (aba \cdot b). Gary quickly solves the problems, writes the three answers on three separate pieces of paper. Then the bell rings and Gary rushes to the lunch line to get as much food as he can!

However, when he comes back, one of the papers is missing! One of his classmates is punishing him for being so greedy. Furthermore, he doesn't remember which of the papers remaining is which, and he also doesn't remember the values aa and bb.

Given the two values, find all possible values for the third value for each of TT test cases.

Input data

The first line contains TT, the number of test cases. Each of the next TT lines contains two numbers aia_i and bib_i, representing the two numbers remaining.

Output data

For each of the TT test cases, the output is on the single line as follows:
The first integer represents the number of possible values for the third value (call this nin_i), while the next nin_i values on the same line represent the different possible values for the third value in increasing order.

Note that if there is no possible value that works, output 00.

Constraints and clarifications

  • 1T1051 \leq T \leq 10^5;
  • 1ai,bi1091 \leq a_i, b_i \leq 10^9;
  • The test cases will be graded individually.

Example

stdin

8
5 7
4 2
10 3
9 3
6 12
2 2
2 256
3 7

stdout

0
2 2 8
0
2 3 27
2 2 72
2 1 4
2 128 512
0

Log in or sign up to be able to send submissions!