#K2301. Counting Lattice Points in a Hypercube

    ID: 24706 Type: Default 1000ms 256MiB

Counting Lattice Points in a Hypercube

Counting Lattice Points in a Hypercube

Given a hypercube in D-dimensional space with a side length L, the task is to compute the number of distinct integer lattice points that lie within or on the boundary of the hypercube. The number of lattice points along each dimension is L+1 (including both endpoints). Thus, the total number of lattice points is given by the formula:

\( (L+1)^D \)

You are to process multiple test cases. For each test case, the first input line contains an integer Q representing the number of queries, followed by Q lines each containing two integers: L (the side length) and D (the number of dimensions). For each test case, output the computed number of lattice points on a new line.

inputFormat

Input is read from stdin and has the following format:

Q
L1 D1
L2 D2
... 
LQ DQ

Here, Q is the number of queries, and each of the subsequent Q lines contains two integers L and D.

outputFormat

The output should be printed to stdout. For each test case, print the number of unique integer lattice points in the defined hypercube on a separate line.

## sample
3
2 1
2 2
2 3
3

9 27

</p>