#include using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef pair pll; typedef long double D; //typedef complex P; #define F first #define S second const ll MOD=1000000007; //const ll MOD=998244353; templateistream & operator >> (istream &i,pair &A){i>>A.F>>A.S; return i;} templateistream & operator >> (istream &i,vector &A){for(auto &I:A){i>>I;} return i;} templateostream & operator << (ostream &o,const pair &A){o<ostream & operator << (ostream &o,const vector &A){int i=A.size(); for(auto &I:A){o<>A>>B; cout<<(gcd(A,B)==1?(A-1)*(B-1)/2:-1)<