Daddy's Task

3.2

32 votes
Problem

Tim and Bob both adores combinatorics. Tim likes rectangles and Bob likes squares. To test there skills one day, daddy brings up a new game where, given the width and height of a rectangular grid, and they have to count the total number of rectangles that can be found on that grid. As Tim and Bob are busy (in another task that we will see in next question) being a good friend and programmer its your duty to help them with the given daddy's task.

For example, width = 3, height = 3 (see diagram below):

3 x 3 grid

In this grid, there are 4 2x3 rectangles, 6 1x3 rectangles, 12 1x2 rectangles, 9 1x1 squares, 4 2x2 squares and 1 3x3 square. Thus there is a total of 4 + 6 + 12 + 9 + 4 + 1= 36 rectangles.

Input

First line contains T denoting number of test cases. Each test case consists of two integers denoting the width and height of the grid.

Output

For each test case, print the required answer in one new line.

Constraints

1 ≤ T ≤ 10

1 ≤ W, H ≤ 1000

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?