I bet that the constraints on both the platforms are different.

In **SPOJ** you can see the constraint on exponent i.e. 0 \leq b \leq 2,147,483,000 which is large enough as compare to the constraint given on **Code-Chef**.

**To solve this problem you need to use modular exponentiation where the modulus value should be 10 as you need to find the last digit of a^b.**

Source-Code for modular-exponentiation:

```
#include<stdio.h>
#include<stdlib.h>
#define MODULUS 10
static int compute_last_digit(int, int);
int main(void) {
int test;
scanf("%d", &test);
while(test--) {
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", compute_last_digit(a, b));
}
return EXIT_SUCCESS;
}
static int compute_last_digit(int base, int exponent) {
int result;
if(!base) {
result = 0;
} else if(!exponent) {
result = 1;
} else {
result = 1;
while(exponent) {
if(exponent & 1) {
result = (result * (base)) % MODULUS;
}
base = (base * base) % MODULUS;
exponent >>= 1;
}
}
return result;
}
```

**EDIT:** I haven’t worked with the `boost/multiprecision in C++`

, so you can try if you want and if the **ONLINE JUDGE** also supports the library, then your program will be accepted on both platforms as **Code-Chef** platform is based on **SPOJ**. But I don’t recommend it, as there is a simple iterative approach to solve the problem as coded above in `C`

.

**Accepted** solution on **Code-Chef**, but it will not be accepted in **SPOJ** due to size error, in **SPOJ** there is size limit on the source-code i.e. `700 bytes`

means your source-code should only have `700`

characters. Follow the above written-source code for acceptance in **SPOJ**.

Thanks for reading.

Peace