#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,a) for(int i=(int)0;i<(int)a;++i) #define pb push_back #define eb emplace_back using ll=long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 60; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; ll gcd(ll n, ll m) { ll tmp; while (m!=0) { tmp = n % m; n = m; m = tmp; } return n; } ll lcm(ll n, ll m) { return abs(n * m) / gcd(n, m);//gl=xy } void solve(){ int a,b; cin>>a>>b; int x=a*b; if(gcd(a,b)!=1)cout<<"-1\n"; else { int cnt=0; rep(i,x+1){ bool flag=false; rep(j,a+1){ rep(k,b+1){ if(k*a+j*b==i){ flag=true; } } } if(!flag)++cnt; } cout<