Panda and Chain Reaction
Practice
4.2 (109 votes)
Ad Hoc
Approved
Basic programming
Easy
Math
Number theory
Open
Problem
34% Success 39724 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

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

  • Subtask 1: (20 points)
    1 <= N, X <= 105

  • Subtask 2: (80 points)
    1 <= N, X <= 1018

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
32 votes
Tags:
ApprovedCombinatoricsEasyImplementationMathOpen
Points:20
58 votes
Tags:
AlgorithmsApprovedEasyMathOpen
Points:20
42 votes
Tags:
ApprovedCombinatoricsEasyMathOpenOthers