#C3165. GCD with Iterative Debugging

    ID: 46562 Type: Default 1000ms 256MiB

GCD with Iterative Debugging

GCD with Iterative Debugging

This problem asks you to compute the Greatest Common Divisor (GCD) of two integers using the Euclidean algorithm while printing the intermediate pairs at each iteration. In each step, print the current values of A and B before updating them, and once B becomes 0, print the final pair (A, 0). The update rule is given by \(A_{new} = B\) and \(B_{new} = A \bmod B\). Your program should read two integers from stdin and output the sequence of printed pairs to stdout.

inputFormat

The input consists of a single line containing two positive integers A and B separated by a space.

outputFormat

Print the intermediate pairs of integers following the Euclidean algorithm. For each iteration, output a line with the current values of A and B separated by a space. When B becomes 0, print the final pair (A, 0). Do not print the returned GCD separately; only the printed pairs should be output.

## sample
48 18
48 18

18 12 12 6 6 0

</p>