#4096. MiaoWu's Function

MiaoWu's Function

MiaoWu's Function

题目描述

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

输入说明

Multiple test cases.

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

输出说明

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

样例

输入

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

输出

1
2
3
4
5
6
7