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

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Dynamic Programming
  4. Dortmund Dilemma

Dortmund Dilemma

Problem
Submissions
Leaderboard
Discussions
Editorial

Borussia Dortmund are a famous football ( soccer ) club from Germany. Apart from their fast-paced style of playing, the thing that makes them unique is the hard to pronounce names of their players ( błaszczykowski , papastathopoulos , großkreutz etc. ).

The team's coach is your friend. He is in a dilemma as he can't decide how to make it easier to call the players by name, during practice sessions. So, you advise him to assign easy names to his players. A name is easy to him if

1. It consists of only one word.
2. It consists of only lowercase english letters.
3. Its length is exactly .
4. It contains exactly different letters from the letters of English alphabet.
5. At least one of its proper prefixes matches with its proper suffix of same length.

Given, and you have to tell him the number of easy names he can choose from modulo .

Note : A prefix of a name is proper if, . Similarly, a suffix of a name is proper if, .

Input Format
The first line of the input will contain ( the number of testcases ). Each of the next lines will contain space separated integers and .

Output Format
For each testcase, output the number of ways the coach can assign names to his players modulo .

Constraints


Sample Input #1

3
1 1
2 1
4 2

Sample Output #1

0  
26 
2600  

Sample Input #2

5  
2 2
5 1
3 2
6 2
1 3

Sample Output #2

0
26
650
13650
0

Author

Bidhan

Difficulty

Advanced

Max Score

150

Submitted By

1687

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy