找规律。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int T,n,m,ans;
int main(){
freopen("A.in","r",stdin);freopen("A.out","w",stdout);
scanf("%d",&T);
while(T--){
scanf("%d%d",&n,&m);n--;m--;
if(n>m)swap(n,m);int t=m-n;
if(!n){printf("%d\n",(t>2)?(t-1)/2+2:t);continue;}
if(t>2)ans=t/2+1;else ans=t;
printf("%d\n",ans+n+1);
}
return 0;
}