#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double PI = 2 * acos(0.0);
void fileIO() {}
long long power(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    n = n / 2;
    x = x * x % mod;
  }
  return res % mod;
}
long long modinv(long long n) { return power(n, mod - 2); }
long long sub(long long a, long long b) {
  if (b == 0) return 1;
  long long ans = ceil((double)(a - b) / b);
  return ans + sub(b, (a - b) % b);
}
void solve() {
  long long a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  long long ans = sub(max(a, b), min(a, b));
  cout << ans;
}
int main() {
  fileIO();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}

### Prompt

Generate a CPP solution to the following problem:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double PI = 2 * acos(0.0);
void fileIO() {}
long long power(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    n = n / 2;
    x = x * x % mod;
  }
  return res % mod;
}
long long modinv(long long n) { return power(n, mod - 2); }
long long sub(long long a, long long b) {
  if (b == 0) return 1;
  long long ans = ceil((double)(a - b) / b);
  return ans + sub(b, (a - b) % b);
}
void solve() {
  long long a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  long long ans = sub(max(a, b), min(a, b));
  cout << ans;
}
int main() {
  fileIO();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}

```