2061 - Power Sum

Created by Carlos Joa Fong
Added by ymondelo20 (2012-10-12)
Limits
Total Time: 5000 MS | Test Time: 2500 MS |Memory: 256 MB | Output: 64 MB | Size: 16 KB
Enabled languages
Available in

Description

Carlos hates math. Specially the kind that deals with large integers.
For his Combinatorics course, help him with the following homework assignment:
Let S(x, n) = 1 + x + x^2 + x^3 + x^4 + ... + x^n.

Given integers x and n, compute S(x, n).
As Carlos despises large integers, print your answer mod prime number 1000000007.
Carlos hates math. Specially the kind that deals with large integers.
For his Combinatorics course, help him with the following homework assignment:
Let S(x, n) = 1 + x + x^2 + x^3 + x^4 + ... + x^n.

Given integers x and n, compute S(x, n).
As Carlos despises large integers, print your answer mod prime number 1000000007.
Carlos hates math. Specially the kind that deals with large integers.
For his Combinatorics course, help him with the following homework assignment:
Let S(x, n) = 1 + x + x^2 + x^3 + x^4 + ... + x^n.

Given integers x and n, compute S(x, n).
As Carlos despises large integers, print your answer mod prime number 1000000007.

Input specification

First line of input contains the number of test cases T (T <= 1000) to follow. Each test case consists of a single line with the two integers x and n (1 <= x <= 10^9 and 0 <= n <= 10^9).
First line of input contains the number of test cases T (T <= 1000) to follow. Each test case consists of a single line with the two integers x and n (1 <= x <= 10^9 and 0 <= n <= 10^9).
First line of input contains the number of test cases T (T <= 1000) to follow. Each test case consists of a single line with the two integers x and n (1 <= x <= 10^9 and 0 <= n <= 10^9).

Output specification

For each test case, output the value of S(x, n) % 1000000007 in a single line.
For each test case, output the value of S(x, n) % 1000000007 in a single line.
First line of input contains the number of test cases T (T <= 1000) to follow. Each test case consists of a single line with the two integers x and n (1 <= x <= 10^9 and 0 <= n <= 10^9).

Sample input

3
10 2
6 5
23 8

Sample output

111
9331
870574954

Hint(s)

http://coj.uci.cu/contest/
http://coj.uci.cu/contest/
http://coj.uci.cu/contest/