#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef pair pii; typedef long long ull; typedef long long ll; typedef vector vi; #define xx first #define yy second #define rep(i, a, n) for (int i = a; i < n; i++) #define sa(n) scanf("%d", &(n)) #define vep(c) for(decltype((c).begin()) it = (c).begin(); it != (c).end(); it++) const int mod = int(1e9) + 7, INF = 0x3fffffff, maxn = 1e5 + 12; ll dfs(int n, int m) { if (n == m) return 1; if (n < m) swap(n, m); return 1 + dfs(n - m, m); } int main(void) { int T; cin >> T; while (T--) { int n, m; sa(n), sa(m); cout << dfs(n, m) << endl; } return 0; }