SP18715 BORING - Boring Factorials (Reloaded)
Description
Factorial is one of the most attractive word this week, it is proposed to reload a famous [problem](http://www.spoj.com/problems/DCEPC11B/). Is it so boring ? Sameer and Arpit want to overcome their fear of Maths and so they have been recently practicing Maths problems a lot. Aman, their friend has been helping them out. But as it goes, Sameer and Arpit have got bored of problems involving factorials. Reason being, the factorials are too easy to calculate in problems as they only require the residue modulo some prime and that is easy to calculate in linear time. So to make things interesting for them, Aman - The Mathemagician, gives them an interesting task. He gives them a prime number **_P_** and an integer **_N_** (not so) close to **_P_**, and asks them to find **_N! modulo P_**. He asks **_T_** such queries.
Input Format
The first line of input contains an integer **_T_**, the number of test cases. On each of the next **_T_** lines, your are given two integers **_N_**, and **_P_** a prime number.
Output Format
For each test case, you have to print **_N! modulo P_**.