跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2568. Subtractions

    ID: 2574 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>数学数论入门难度共享题库Codeforces英文题面题目来源题面语言

Subtractions

题目描述

A. Subtractions
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5).

You've got some number of pairs (ai,bi). How many operations will be performed for each of them?

Input

The first line contains the number of pairs n (1≤n≤1000). Then follow n lines, each line contains a pair of positive integers ai,bi (1≤ai,bi≤109).

Output

Print the sought number of operations for each pair on a single line.

Examples
Input
2
4 17
7 987654321
Output
8
141093479

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 2216 题。保留原作者与原赛事署名。