Last Digit

Time Limit: 1 sec

**The Problem**

Given you a positive integer N (N < 10^10000000). Please Compute

S = N[0]^N[0] + N[1]^N[1] + N[2]^N[2] + . . . + N[length(N)-1]^N[length(N)-1]

Then find out the last digit of S....

For example

If N = 123

So, N[0] = 1, N[1] = 2 and N[2] = 3

S = 1^1 + 2^2 + 3^3

= 1 + 4 + 27

= 32

So the last digit is 2

[Note: The number can be contain leading zeros]

**The Input**

Input file consists several line of input. Each line of input contain a positive integer N. Input is terminated with -1.

**The Output**

For each line of input you need to print a single line which contains the last digit of S.

**Sample Input**

123

166

789

-1

**Sample Output**

2

3

8

[Outsbook Round #2 Online Contest]

Problem Setter: Soikat Dutta