We are given a N*M grid, print the number of rectangles in it modulo (10^{9}+7).
 
Example 1:
Input:
N = 2, M = 2
Output:
9
Explanation:
There are 4 rectangles of size 1 x 1
There are 2 rectangles of size 1 x 2
There are 2 rectangles of size 2 x 1
There is  1 rectangle of size 2 X 2.
Example 2:
Input:
N = 5, M = 4
Output:
150
Explanation:
There are a total of 150 rectangles.
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function rectNum() which takes 2 Integers N and M as input and returns the number of rectangles in a N*M grid modulo (10^{9}+7).
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= N,M <= 10^{4}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def rectNum(self, N, M):

        # code here

Solutions:
class Solution:

	def rectNum(self, N, M):
		return int(N * M * (N + 1) * (M + 1) / 4 % 1000000007)


class Solution:

	def factorial(self, n):
		fact = 1
		for i in range(1, n + 1):
			fact = fact * i
		return fact

	def combination(self, n, r):
		up = self.factorial(n)
		left = self.factorial(n - r) * self.factorial(r)
		return up // left

	def rectNum(self, N, M):
		N = N + 1
		M = M + 1
		v = N * (N - 1) // 2 % (10 ** 9 + 7)
		r = M * (M - 1) // 2 % (10 ** 9 + 7)
		return v * r % (10 ** 9 + 7)


class Solution:

	def rectNum(self, N, M):
		return N * (N + 1) * M * (M + 1) // 4 % (10 ** 9 + 7)


class Solution:

	def rectNum(self, n, m):
		return n * (n + 1) * (m + 1) * m // 4 % 1000000007


class Solution:

	def rectNum(self, N, M):
		return (N ** 2 + N) // 2 * ((M ** 2 + M) // 2) % (10 ** 9 + 7)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(N, M) = map(int, input().split())
		ob = Solution()
		print(ob.rectNum(N, M))


class Solution:

	def rectNum(self, N, M):
		return N * (N + 1) // 2 * M * (M + 1) // 2 % 1000000007
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(N, M) = map(int, input().split())
		ob = Solution()
		print(ob.rectNum(N, M))