Why it is not running and passing the compile cases

Scanner scn = new Scanner(System.in);
int T = scn.nextInt();
for(int t=1 ; t<=T ; t++)
{
long n =scn.nextInt();
long k = scn.nextInt();
long ans=0;
long i=0;
long j =(long)Math.pow(10,18);
while(i<=j)
{
long mid=(i+j)/2;
long c=(long)Math.pow(mid,k);

		if(c<=n)
		{
			ans=mid;
			i=mid+1;
		}
		else
		{
			j=mid-1;
		}
	}
	System.out.println(ans);
	}
}

}

use nextLong()

long n =scn.nextLong();
long k = scn.nextLong();