#include<cstdio>
#include<iostream>
using namespace std;
int t;
int x,y;
int n,ans;
int abs(int a)
{
if(a<0)
return -a;
return a;
}
int solve()
{
if(n==x&&y!=-n)
{
return y+(n-1);
}
else
{
if(y==n)
{
return 2*n-1+n-x;
}
else
{
if(x==-n)
{
return 4*n-1+n-y;
}
else
{
if(-y==n)
{
return 6*n-1+x+n;
}
}
}
}
}
int main()
{
cin>>t;
while(t--)
{
cin>>x>>y;
n=max(abs(x),abs(y));
ans=(2*n-1)*(2*n-1);
ans+=solve();
cout<<ans<<endl;
}
return 0;
}