There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.

Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, given n, print the last digit of 1378^{n}. 

 [Image] 

Mehrdad has become quite confused and wants you to help him. Please help, although it's a naive cheat.


-----Input-----

The single line of input contains one integer n (0  ≤  n  ≤  10^9).


-----Output-----

Print single integer — the last digit of 1378^{n}.


-----Examples-----
Input
1

Output
8
Input
2

Output
4


-----Note-----

In the first example, last digit of 1378^1 = 1378 is 8.

In the second example, last digit of 1378^2 = 1378·1378 = 1898884 is 4.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
print(pow(1378, n, 10))


n = int(input())
print(pow(8, n, 10))


import math

N = int(input())

print(pow(1378, N, 100) % 10)

print(pow(1378,int(input()),10))

import sys
n = int(input())
if n == 0:
    print(1)
    return
if n % 4 == 0:
    print(6)
elif n % 4 == 1:
    print(8)
elif n % 4 == 2:
    print(4)
else:
    print(2)


print(pow(1378,int(input()),10))


n = int(input())
if n == 0:
    print(1)
elif n % 4 == 1:
    print(8)
elif n % 4 == 2:
    print(4)
elif n %4  == 3:
    print(2)
else:
    print(6)

#!/usr/bin/env python3

def main():
    try:
        while True:
            n = int(input())
            x = 1
            a = 1378
            while n != 0:
                if n & 0x1:
                    x *= a
                    x %= 10000
                a *= a
                a %= 10000
                n >>= 1

            print(x % 10)

    except EOFError:
        pass

main()


n = int(input())
line = [8, 4, 2, 6]
if n > 0:
    print(line[(n-1) % 4])
else:
    print(1)

n = int(input())
arr = [1, 8, 4, 2, 6]
if n == 0:
    print(1)
elif n % 4 == 0:
    print(6)
else:
    print(arr[n % 4])


#cf383 yl 1
n=int(input())
#l=list(map(int,input().split()))
if n==0:
    print(1)
else:
    print([6,8, 4, 2, 6, 8, 4][n%4])


n = int(input())
print(pow(8, n, 10))


def fastexp(x,n,m):
    result = 1
    currentpower = x
    while n > 0:
        if n % 2 == 1:
            result = (result * currentpower) % m

        currentpower = (currentpower * currentpower) % m
        n = n//2

    return result

a = int(input())
b=fastexp(8, a, 10)
print(b)

def power(a, pow1, MOD): #������� ���������� � ������� �� ������ MOD
    if pow1 == 0:
        return 1
    elif pow1 % 2 == 1:
        return (power(a, pow1 - 1, MOD) * a) % MOD
    else:
        return (power(a, pow1 // 2, MOD) ** 2) % MOD

n = int(input())
MOD = 10

print(power(1378, n, MOD))


n = int(input())
if n == 0:
    print(1)
elif n % 4 == 1:
    print(8)
elif n % 4 == 2:
    print(4)
elif n % 4 == 3:
    print(2)
elif n % 4 == 0:
    print(6)

import sys

import math


sz=int(input())
if sz==0:
    print(1)
    return

s = str(8 ** ((sz - 1) % 4 + 1))
print(s[len(s)-1])

s = int(input())

if (s == 0): print("1");
if (s % 4 == 0 and s != 0): print("6")
if (s % 4 == 1): print("8")
if (s % 4 == 2): print("4")
if (s % 4 == 3): print("2")

n = int(input())
if n == 0:
    print(1)
elif (n % 4 == 0):
    print(6)
elif (n % 4 == 1):
    print(8)
elif (n % 4 == 2):
    print(4)
else:
    print(2)

k = int(input().strip())
n = k%4
if k == 0:
	print(1)
elif n == 0:
	print(6)
elif n == 1:
	print(8)
elif n == 2:
	print(4)
else:
	print(2)

n = int(input())
if n==0: print(1)
elif n%4==1: print(8)
elif n%4==2: print(4)
elif n%4==3: print(2)
elif n%4==0: print(6)


def __starting_point():
	n, = map(int, input().split())
	if n == 0:
		print(1)
	elif n % 4 == 0:
		print(6)
	elif n % 4 == 1:
		print(8)
	elif n % 4 == 2:
		print(4)
	else:
		print(2)
__starting_point()

n=int(input())
if n==0:
    print(1)
else:
    k=n%4+4
    print(8**k%10)


n = int(input())
if n:
  print([6,8,4,2][n%4])
else:
  print(1)  

n = int(input())
if n == 0:
    print('1')
elif n % 4 == 1:
    print('8')
elif n % 4 == 2:
    print('4')
elif n % 4 == 3:
    print('2')
else:
    print('6')


a = [8, 4, 2, 6]
n = int(input())
if n == 0:
    print(1)
else:
    print(a[(n-1) % 4])