Killjee And Sequence

5

1 votes
Medium-Hard
Problem

Killjee is very weak in mathematics and everyone is sure that he will fail in mathematics this year like previous years. Somehow killjee found the question of final exams and now he is asking for your help to solve the question.

Sk=r1i=0(ki(i+1)2i+1)

SS=nk=r(r+1)2(nk)Sk

Compute SS.

Input:

First line of input contains a single integer T denoting the number of test cases. Each of the next T lines contains 2 integers, n and r, as described in the problem statement.

Output:

Print the answer to each query modulo 1010+19.

Constraints:

1T10

1n1018

1r2000

Sample Input
2
8 3
9 3
Sample Output
6720
40320
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?