#include <bits/stdc++.h>
inline long long int no_of_digits(long long int n) {
  return 1 + floor(log10(n));
}
using namespace std;
long long int check(long long int, long long int);
long long int counti;
int main() {
  long long int i, j, k, m, n, q, t, count1, count2, temp1, temp2;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j >> k;
    count1 = 0;
    if (j == k)
      cout << 1 << "\n";
    else {
      while (j != k) {
        if (j == 0 or k == 0) {
          break;
        } else if (j < k) {
          count1 += (k / j);
          k = k - (j * (k / j));
        } else if (k < j) {
          count1 += (j / k);
          j = j - (k * (j / k));
        } else {
          count1++;
          break;
        }
      }
      if (j == k)
        cout << count1 + 1 << "\n";
      else
        cout << count1 << "\n";
    }
  }
  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>
inline long long int no_of_digits(long long int n) {
  return 1 + floor(log10(n));
}
using namespace std;
long long int check(long long int, long long int);
long long int counti;
int main() {
  long long int i, j, k, m, n, q, t, count1, count2, temp1, temp2;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j >> k;
    count1 = 0;
    if (j == k)
      cout << 1 << "\n";
    else {
      while (j != k) {
        if (j == 0 or k == 0) {
          break;
        } else if (j < k) {
          count1 += (k / j);
          k = k - (j * (k / j));
        } else if (k < j) {
          count1 += (j / k);
          j = j - (k * (j / k));
        } else {
          count1++;
          break;
        }
      }
      if (j == k)
        cout << count1 + 1 << "\n";
      else
        cout << count1 << "\n";
    }
  }
  return 0;
}

```