xy

Time limit: 0.2s Memory limit: 256MB Input: Output:

Kaloyan was preparing an exam for his students and found the following problem to be pretty interesting. He wrote two numbers XX and YY and wants to find a sequence of integers where the sum of every XX consecutive elements (in the sequence) is strictly positive while the sum of every YY consecutive elements is strictly negative.

Task

Kaloyan found out that this sequence cannot be infinitely long. He tried to find a sequence of maximum possible length with the described property. However, it turns out to be rather difficult problem for Kaloyan. Help him by writing a program that finds the maximum length of such a sequence. You should find the answers to QQ such pairs XX and YY. Additionally, you have to find a maximal sequence only for the first query.

Input data

The first line of the standard input contains one integer QQ — the number of queries.

Each of the following QQ lines contains two integers — XX and YY.

Output data

On the first line of the standard output you should print QQ numbers — N1 N2NQN_1 \ N_2 \dots N_Q, separated with spaces, where NiN_i is the answer for the ii-th query. On the second line you should print N1N_1 integers separated with spaces — a sequence with the desired property for the first query.

Constraints and clarifications

  • 1X,Y,Q100 0001 \leq X, Y, Q \leq 100 \ 000
  • The numbers in the sequence must be between 109-10^9 and 10910^9
# Score Constraints
1 0 Example
2 3 X=YX = Y for all queries
3 4 XX divides YY or YY divides XX for all queries
4 9 Q=1Q = 1, X,Y5X, Y \leq 5
5 12 abs{XY}\text{abs}\{X - Y\} = 11
6 15 1X,Y,Q1001 \leq X, Y, Q \leq 100
7 22 1X,Y,Q1 0001 \leq X, Y, Q \leq 1 \ 000
8 35 No additional constraints

Example

stdin

3
3 5
1 5
4 2

stdout

6 4 3
5 -7 5 3 -7 5

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