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. Combinatorics
  4. Merge List

Merge List

Problem
Submissions
Leaderboard
Discussions
Editorial

Shashank is very excited after learning about the linked list. He learned about how to merge two linked lists. When we merge two linked lists, the order of the elements of each list doesn't change. For example, if we merge and , is a valid merge, while is not a valid merge because appears before .

Shashank wants you to solve a problem for him: You are given two lists having sizes and . How many ways can we merge both the lists? It is given that all elements are distinct. As your answer can be quite large, Shashank wants you to print it .

Input Format

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

Constraints

Output Format

Print the value of the answer .

Sample Input 0

1
2 2

Sample Output 0

6

Explanation 0

Suppose the two lists are and . The different ways of merging these lists are given below:






Author

amititkgp

Difficulty

Medium

Max Score

40

Submitted By

2529

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

Join us

Create a HackerRank account

Be part of a 26 million-strong community of developers

Please signup or login in order to view this challenge

or
Already have an account?Log in