#include #include #include #include #include #include #include #include #include using namespace std; #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (b) - 1; i >= (a); i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define sz(x) ((int)(x).size()) typedef vector vi; typedef long long ll; typedef pair pii; int main() { int t; cin >> t; while (t--) { int n, m; cin >> n >> m; int ans = 0; while (n && m) { if (n > m) swap(n, m); m -= n; ans++; } cout << ans << endl; } return 0; }