Panda and Chain Reaction
Tag(s):

## Ad-Hoc, Basic Programming, Easy, Mathematics, Modular exponentiation, Number Theory

Problem
Editorial
Analytics

Panda has become a scientist recently. In his laboratory, there are infinite number of chambers where a chamber number K is connected to a chamber number K-1.

The numbering of chambers start from 0. Initially, X number of particles are present in the chamber number 0. The number of particles present in chamber K is K times the number of particles present in chamber K-1. You are supposed to help Panda in finding out the number of particles in a given chamber number N.

Note: The number of particles in chamber K cannot be calculated until the number of particles in chamber K-1 are calculated.

Input Format:

The first line will contain the integer T, the number of test cases. Each test case consists of two space separated integers N and X.

Output Format:

For each test case, output the answer to Panda's query. Since the output can be very large, output the answer modulo 106+3.

Constraints:

1 <= T <= 105

1 <= N, X <= 105

1 <= N, X <= 1018

SAMPLE INPUT
2
1 3
2 1

SAMPLE OUTPUT
3
2

Explanation

Case 1: For first test case, initially there were 3 particles. In Chamber K=1, the number of particles became 1*3 = 3.

Case 2: Initially, there is only 1 particle. In Chamber K=1, the number of particle became 1*1 = 1. In Chamber K=2, the number of particle became 2*1 = 2.

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...

## This Problem was Asked in Challenge Name

May Easy Challenge '15

OTHER PROBLEMS OF THIS CHALLENGE
• Math > Basic Math
• Math > Basic Math
• Algorithms > Graphs
• Algorithms > Dynamic Programming