a题
*****************************************************
如果ab在原点的横轴和纵轴上则无解
否则直接到aa,bb点中的较小者再到终点
模拟知差值为奇数走1偶数走4
*****************************************************
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstring>
#include<string>
#include<queue>
using namespace std;
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--)
{
int a,b;
cin>>a>>b;
if((a==1&&b>2)||(a>2&&b==1)) cout<<"-1"<<endl;
else
{
if(a<b) swap(a,b);
int sum=(b-1)*2;
sum+=(a-b)/2*4+(a-b)%2*1;//有几个偶数
cout<<sum<<endl;
}
}
return 0;
}