#include #include using namespace std; int main() { int t; cin>>t; while(t--) { int n,m; cin>>n>>m; int ans=0; int a=max(n,m); int b=min(n,m); while(b!=0) { ans+=a/b; int t=a; a=b;b=t%b; } cout<