All Tracks Math Problem

Double Factorial
Tag(s):

Ad-Hoc, Easy, Mathamatics, Mathematics

Problem
Editorial
Analytics

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

SAMPLE INPUT
2
1 4
1 2
SAMPLE OUTPUT
1
1
Time Limit: 2,0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

February Love

OTHER PROBLEMS OF THIS CHALLENGE
Уведомления
View All Notifications

?