- Practice
- Mathematics
- Algebra
- Little Gaurav and Sequence

# Little Gaurav and Sequence

# Little Gaurav and Sequence

Little Gaurav is very fond of numbers and sequences. One day his teacher tells him to find a strange sequence.

Since this sequence looks a bit difficult, the teacher tells him to find the last digit of .

Little Gaurav is confused because he cannot solve the problem and leaves this problem to the worthy programmers of the world. Help little Gaurav in finding the solution.

**Input Format**

The first line contains , the number of test cases.

lines follow, each line containing an integer, .

**Output Format**

For each testcase, print the last digit of in one line.

**Constraints**

**Sample Input**

```
3
1
2
3
```

**Sample Output**

```
0
6
0
```

**Explanation**

For n=1, only i=0 is valid. So S is . Hence last digit of S is 0.

For n=2, only i=0 and 1 are valid. So S is

S1(for i=0) is .

S2(for i=1) is .

So last digit of S is 6.