#K36462. Minimum Power Calculation
Minimum Power Calculation
Minimum Power Calculation
You are given a series of test cases. For each test case, you are provided with a single integer \(n\). Your task is to calculate the factorial of \(n\) modulo a given integer \(M\). In other words, compute \(n! \bmod M\), where \(n! = 1 \times 2 \times \cdots \times n\).
Note that if \(M = 1\), the result will always be 0, because any number modulo 1 is 0.
inputFormat
The input is given via standard input. The first line contains two integers, \(T\) and \(M\), separated by a space, where \(T\) is the number of test cases and \(M\) is the modulo value. Each of the next \(T\) lines contains one integer \(n\), representing the number for which you need to compute \(n! \bmod M\).
outputFormat
For each test case, output a single line containing the computed value of \(n! \bmod M\).
## sample1 100
3
6
</p>