Double Factorial
Practice
4.2 (5 votes)
Ad Hoc
Mathematics
Open
Approved
Easy
Mathamatics
Problem
22% Success 16177 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

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

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
4 votes
Tags:
Easy
Points:20
1 votes
Tags:
Easy
Points:20
10 votes
Tags:
OpenAlgorithmsApprovedEasyMathamatics