We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Number Theory
  4. nCr

nCr

Problem
Submissions
Leaderboard
Discussions
Editorial

Given two integers and . In how many ways can items be chosen from items?

Input Format

The first line contains the number of test cases . Each of the next lines contains two integers and .

Constraints



Output Format

Output lines, containing the required answer for the corresponding test case. Output all answers modulo .

Sample Input

4
2 1
4 0
5 2
10 3

Sample Output

2
1
10
120

Author

HackerRank

Difficulty

Expert

Max Score

120

Submitted By

3124

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website