10621: MiaoWu's Function

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:1 Solved:0

Description

Given n,k and the function f(n,k) = 1^k + 2^k + ... + n^k , you're supposed to calculate it.

Input

Multiple test cases.

Each line contains two numbers n,k(1<=n,k<=10^9)

Output

Output the last digit of the function f(n,k)

Sample Input Copy

1 1
8 4
2 5
3 2
5 2
8 3
2 4

Sample Output Copy

1
2
3
4
5
6
7