P20995 [HackerEarth] SKIT's Language Department are studying an incredible string which is actually a palindrome.
普及
题目描述

SKIT's Language Department are studying an incredible string which is actually a palindrome.
The students are trying to build all possible incredible strings that contains 1 to K lowercase characters.

Their is a constraint to the string which makes it incredible that each string can contain at most M distinct characters.

Your task is to help those students by finding out the total number of possible incredible strings.

Note: Answer could be very large, hence print answer modulo 1234567891.

Input:

First line of input contains an integer T denoting the number of test cases.
Each test case contains two space separated integers K and M.

Output:

Print the total number of possible strings.

Constraints:
1 ≤ T ≤ 25
1 ≤ K ≤ 10^9
1 ≤ M ≤ 26

SAMPLE INPUT
2
1 1
2 10

SAMPLE OUTPUT
26
52

Explanation

Test Case #1:

All single character strings constitute the list of incredible strings.

Test Case #2:

All single character and two characters strings are incredible strings.

输入格式

见题面

输出格式

见题面

样例输入
22 1 1 2 10 3 2 44 7 1000000000 26 999999999 25 23 23 40 19 39 19 1000000000 1 757148 26 301413357 26 659598369 26 391749388 26 35766291 26 473038165 26 3615545 26 392289611 26 170427799 26 675016434 26 100757147 19 401413356 23
样例输出
706606893 15745476 384108829 333945499 480834182 198470272 517605484 652883421 198470272 1126070080 1049716493 318667120 522071800 1232051448 460019892 389687257 482302736 1222160695 868920764 946932112 138511467 776103748