Continued Fraction
题号:NC229227
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

A continued fraction is an expression of the form:

where  are nonnegative integers.

Given a fraction (x,y are positive integers), please expand it into a continued fraction.

输入描述:

The first line contains an integer T (), denoting the number of test cases.

The only line of each test case contains two integers x, y (), denoting a fraction . It's guaranteed that .

输出描述:

For each test case, output one line: first an integer n denoting the height of the continued fraction, then  integers denoting . Your solution should gurarantee that , .

If there are multiple valid solutions, you only need to output one of them.
示例1

输入

复制
2
105 38
1 114

输出

复制
4 2 1 3 4 2
1 0 114

说明

For the convenience of you, we give explanation of sample:
\frac{105}{38}=2+\dfrac{1}{1+\dfrac{1}{3+\dfrac{1}{4+\dfrac12}}}

\frac{1}{114}=0+\dfrac{1}{114}