#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;xb) { return a/b+1+dp(b,a%b); } else { return 1+dp(b,a); } } void solve() { int i,j,k,l,r,x,y; string s; cin>>M>>N; ll g=__gcd(N,M); N/=g; M/=g; cout<