https://vjudge.net/contest/278754#problem/E
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
ll i,j,k,l,n,m,ans,k2,a,b,kk,k1;
int main()
{
scanf("%lld",&n);
for (i=1; i<=n; i++)
{
scanf("%d%d",&a,&b);
if (a>2||a==0) printf("-1 -1\n");
if (a==1) printf("1 %lld\n",b+1);
if (a==2)
{
if(b%2==0)
{
k=b/2-1;
k1=k*(k+2);
k2=k*(k+2)+2;
printf("%lld %lld\n",k1,k2);
}
else
{
k=b-1;
k1=k*(k+2);
k2=k*(k+2)+2;
if(k1%2==0&&k2%2==0)
printf("%lld %lld\n",k1/2,k2/2);
else
printf("-1 -1\n");
}
}
}
}