THE LAST DIGIT

i have made a way to assign the last number but on uploading it on spoj it says wrong answer . can anyone can help to sort out this problem.
my code is:

#include
#include
using namespace std;
int main()
{
short int t;
cin>>t;
if(t<=30)
{while(t-- )
{short int a;
short int r=0;
long long int b,c;
cin>>a>>b;
if(a==0 && b==0)
{
break;
}
else if(b==0)
{
cout<<“1\n”;
}
else if(a==0)
{
cout<<“0\n”;
}
else
{
r=b%4;
if(r==0)
{
c=a%2;
if(c==0)
cout<<“6\n”;
else if(c==1)
cout<<“1\n”;
}
else
{
c=pow(a,r);
c=c%10;
cout<<c<<endl;
}
}
}
}
return 0;
}

your code is giving wrong output on testcase:

input:

2

20 2147483000

10 2147483000

15 2147483000

expected output:

0

0

5

your code output:

6
6
1

you can check here

thank you it worked