#include
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ll t;
cin>>t;
while(t–)
{
ll x,y;
cin>>x>>y;
if(x==y)
cout<<0<<endl;
else if(x>=0 && y>=0)
{
if((y-x)>0)
{
if((y-x)%2==0)
cout<<2<<endl;
else
cout<<1<<endl;
}
else if((y-x)<0)
{
if(((abs(y-x))%2)!=0)
cout<<2<<endl;
else
cout<<1<<endl;
}
}
// else if((x%2)==0 && (x>0) && ((y%2)!=0 && y<0))
// cout<<2<<endl;
// else if((x%2)!=0 && (x>0) && ((y%2)==0 && y<0))
// cout<<2<<endl;
// else if((x%2)==0 && (x<0) && ((y%2)==0 && y>0))
// cout<<2<<endl;
// else
// cout<<1<<endl;
else if((x<0 && y<0) || (x<0 || y<0))
{
if((x%2)==0 && (x>0) && ((abs(y))%2)!=0 && (y<0))
cout<<2<<endl;
else if((abs(x))%2==0 && (x<0) && ((abs(y))%2)!=0 && (y<0))
cout<<2<<endl;
else if(((abs(x))%2)!=0 && (x<0) && (y%2)==0 && (y>0))
cout<<1<<endl;
else if(((abs(x))%2)!=0 && (x<0) && ((abs(y))%2==0) && (y<0))
cout<<1<<endl;
else if((abs(x%2))!=0 && (x<0) && (((abs(y))%2)!=0) && (y>0))
cout<<2<<endl;
else if((abs(x))%2==0 && (x<0) && (y%2)==0 && (y>0))
cout<<2<<endl;
else if((x%2)!=0 && (x>0) && ((abs(y))%2==0) && (y<0))
cout<<2<<endl;
else
cout<<1<<endl;
}
}
return 0;
}
This is first one of infinity 2k20 can someone tell where I have missed some cases. and how to improve it?