12521252 SUSTech Online Judge
Problem 1252 --[Median I] Factorial Magic

1252: [Median I] Factorial Magic

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1179  Solved: 238
[Submit][Status][Web Board]


Neko is a freshman at SUSTech and he is good at fractorial problems. He wants to challenge you to see if you can solve the following problem: Caculate the value of \(((n!)!)!(mod\space m)\).


There is only one line contains two integers \(n,m,(0{\leq}n{\leq}10^9,1{\leq}m{\leq}10^9)\).


Print the value of \(((n!)!)!(mod\space m)\).

Sample Input

1 2019

Sample Output



In mathematics, the factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n: For example, The value of 0! is 1, according to the convention for an empty product.