Double Factorial

4.2

5 votes
Ad-Hoc, Mathematics, Open, Approved, Easy, Mathamatics
Problem

Kuldeep is tired from all the fun he's having with Christie, so now all he needs is a good night's sleep to get some rest.

Being a math nerd, he even dreams about maths.

But in this dreamland some mathematical entities have slightly different definition. For example factorial of a number n in dreamland is defined as (n!)! (double factorial )

Since Kuldeep is facinated with factorials in real life, he takes upon himself to find out values of factorials in dreamland, and because the answers can be very large, he is only interested in calculating double factorial mod 10^M(^ is power operator not xor operator).

Your task is to help him to find out the answer .

Input :

First line of input file contain integer T (number of test cases) and next T lines contains two integers N and M.

Output:

Output the value (N!)! modulo 10^M (here ^ is used for power operator not xor operator) .

Constraints:

1<=T<=100000
0<=N<=10^6
0<=M<=19

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?