Given a positive integer , compute the value of the following expression modulo
:
Where:
The binomial coefficient is defined as:
The factorial is defined as the product of all positive integers from
to
:
The modulo operation returns the remainder when
is divided by
. For example:
You need to output the value of the expression modulo .
There are multiple test cases. The first line of the input contains a single integer
![]()
, denoting the number of test cases. For each test case:
The first and only line contains one integer
![]()
.
For each test case, output one line containing one integer, denoting the value of the expression modulo
.
For the first sample test case,
, so you need to compute the following expression:
Let’s analyze each row of binomial coefficients modulo
:
:
:
,
:
,
,
:
,
,
,
So the total sum is . And you need to output
.
For the second sample test case, , so you need to compute the following expression:
Similarly:
:
:
sum =
:
sum =
:
sum =
:
sum =
:
sum =
Final result:
For the third sample test case, I have a brilliant explanation, but the space here is too small to writ