Help me in solving PMD7 problem

My issue

I am getting correct output but submission gets failed. Why??

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
	 double n=0;
		int r;
		
		for(int i=1;i<=t;i++)
		{
		  int a=sc.nextInt();
		  int b=sc.nextInt();
		  while(a!=0)
		  {
		    r=a%10;
		    n=n*10+(Math.pow(r,b)%10);
		    a=a/10;
		  }
		  if(n%7==0)
		  {
		    System.out.println("Yes");
		  }
		  else{
		    System.out.println("no");
		  }
}
}
}

Problem Link: CodeChef: Practical coding for everyone

@reddytanuj7
For calculating power u may get integer overflow that is why u r getting wa.