B - A^B^C Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 400

問題文

正の整数 A,B,C が与えられます。A^{B^C}10 進法での 1 の位を求めてください。

制約

  • 1\leq A,B,C \leq 10^9
  • A,B,C は整数である

入力

入力は以下の形式で標準入力から与えられる。

A B C

出力

A^{B^C}10 進法での 1 の位を出力せよ。


入力例 1

4 3 2

出力例 1

4

4^{3^2}=4^9=2621441 の位は 4 です。


入力例 2

1 2 3

出力例 2

1

入力例 3

3141592 6535897 9323846

出力例 3

2

Score : 400 points

Problem Statement

Given positive integers A, B, C, find the digit at the ones place in the decimal notation of A^{B^C}.

Constraints

  • 1\leq A,B,C \leq 10^9
  • A,B,C are integers.

Input

Input is given from Standard Input in the following format:

A B C

Output

Print the digit at the one's place in the decimal notation of A^{B^C}.


Sample Input 1

4 3 2

Sample Output 1

4

The ones digit in the decimal notation of 4^{3^2}=4^9=262144 is 4.


Sample Input 2

1 2 3

Sample Output 2

1

Sample Input 3

3141592 6535897 9323846

Sample Output 3

2