Under construction

Still being built. Things may change

Last Factorial Digit

Time limit1sMemory limit1024 MB

Summary
Given up to 10 values of N (N at most 10), print the last decimal digit of N! for each.
Level

Easy1 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

The factorial of NN, written as N!N!, is the product of all integers from 1 to NN. For example, 3!=1×2×3=63! = 1 \times 2 \times 3 = 6.

This number can get very large, so instead of computing the full product, compute only the last digit of N!N! when it is written in base 10.

Input

The first line contains a positive integer TT (1≤T≤101 \leq T \leq 10), the number of test cases. Each of the next TT lines contains a single positive integer NN. NN is at most 10.

Output

For each value of NN, print the last digit of N!N!.

Examples2

  1. Example 1

    Input
    3
    1
    2
    3
    
    Expected output
    1
    2
    6
    
  2. Example 2

    Input
    2
    5
    2
    
    Expected output
    0
    2