Continued fraction#256

Continued fraction

1 second
64 megabytes
Very easy

A continued fraction is an expression of the form:

In this expression, a_0 is an integer, and the other a_n are positive integers. Continued fractions are interesting because they can represent any real number. For rational numbers, a continued fraction is finite, while for irrational numbers it is infinite.

For example, the number can be represented as a continued fraction: 9/4 = 2 + 1/(3+1/1).

This fraction can also be expressed as: 9/4 = 2 + 1/4.

Your task is to find the minimal continued fraction representation for a given rational number .

Input

The first line of the input contains two integers and (1 \leq p,\ q \leq 10^3).

Output

On the first line of the output, print the number , which is the number of terms in the continued fraction equal to . On the second line, print the numbers a_0, a_1, \ldots, a_n separated by spaces.

Examples

Example 1

Loading
Loading