There are many ways to build very large numbers. Two of them are:
- Exponentiation: 422016=2016 times42×42×⋯×42
- Factorials: 2016!=2016×2015×⋯×2×1
This problem uses their lesser known combination, the exponial, which is defined for every positive integer n as
exponial(n)=n(n−1)(n−2)⋯21
For example, exponial(1)=1 and exponial(5)=54321≈6.206×10183230, which is already very large. Exponentiation is right associative, so abc=a(bc).
Exponials are too large to handle directly. Write a program that computes the remainder of exponial(n) divided by m.