Construct an N \times M matrix with entries having positive integers such that:

If M > 1, i^{th} row is strictly increasing from left to right with a fixed common difference d_{i} for all 1≤ i ≤ N.
If N > 1, j^{th} column is strictly increasing from top to bottom with a fixed common difference c_{j} for all 1≤ j ≤ M.
All the common differences should be distinct.
In the case of multiple answers, find an arrangement that minimizes the maximum element of the matrix. 

------ Input Format ------ 

- First line will contain T, number of test cases. Then the test cases follow.
- Each test case contains a single line of input, two space-separated integers N and M - the dimensions of the matrix.

------ Output Format ------ 

For each test case, output N lines with each line having M space-separated integers representing the answer.

------ Constraints ------ 

$1 ≤ T ≤ 10$
$1 ≤ N, M ≤ 10^{5}$
- Sum $N \cdot M$ over all cases is atmost $10^{5}$.

----- Sample Input 1 ------ 
3
3 3
1 2
1 1

----- Sample Output 1 ------ 
1 2 3
3 6 9
5 10 15
1 2
1

----- explanation 1 ------ 
Test case $1$: The values $d_{1}, d_{2},$ and $d_{3}$ are $1, 3,$ and $5$ respectively. The values $c_{1}, c_{2},$ and $c_{3}$ are $2, 4,$ and $6$ respectively. Note that all these common differences $\{d_{1}, d_{2}, d_{3}, c_{1}, c_{2}, c_{3}\}$ are distinct. Moreover, it can be shown that over all valid matrices, $15$ is the minimal value of the maximum element of the matrix one can achieve.

Test case $2$: The values $d_{1}$ is $1$. It can be shown that over all valid matrices, $2$ is the minimal value of the maximum element of the matrix one can achieve.

Difficulty: MEDIUM

Solutions:
t = int(input())
while t:
	(n, m) = map(int, input().split())
	arr = [[0 for i in range(m)] for j in range(n)]
	val = 1
	r = 1
	c = 2
	if m > n:
		c = n + 1
	elif n > m:
		c = 1
		r = m + 1
	for i in range(n):
		temp = val
		for j in range(m):
			arr[i][j] = val
			val += r
		val = temp + c
		if n == m:
			r += 2
		else:
			r += 1
	for i in range(n):
		print(*arr[i])
	t -= 1


import math
import collections
import itertools
import functools

def fun(t):
	(n, m) = map(int, input().split(' '))
	ans = []
	dif = 0
	if m == n:
		for i in range(n):
			temp = []
			dif += 1
			temp.append(dif)
			for j in range(1, m):
				temp.append(dif * (j + 1))
			ans.append(temp)
			dif += 1
		for l in ans:
			print(*l)
	elif n > m:
		d = 2 * min(m, n) + abs(m - n)
		op = 1
		for i in range(n):
			temp = []
			for j in range(m):
				temp.append(op + d * j)
			print(*temp)
			op += min(m, n)
			d -= 1
	else:
		d = min(m, n)
		op = 1
		for i in range(n):
			temp = []
			for j in range(m):
				temp.append(op + d * j)
			print(*temp)
			op += 2 * min(m, n) + abs(m - n)
			d -= 1
for tc in range(int(input())):
	fun(tc)


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	l = [[0 for i in range(n)] for j in range(m)]
	if m > n:
		c = 1
		r = n + 1
		for i in range(m):
			l[i][0] = c
			for j in range(1, n):
				l[i][j] = l[i][j - 1] + r
			r += 1
			c += 1
	elif m == n:
		c = 1
		for i in range(m):
			l[i][0] = c
			for j in range(1, n):
				l[i][j] = l[i][j - 1] + c
			c += 2
	else:
		r = 1
		x = 1
		for i in range(m):
			l[i][0] = x
			for j in range(1, n):
				l[i][j] = l[i][j - 1] + r
			r += 1
			x += m + 1
	for i in l:
		print(*i)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if n > m:
		for i in range(n):
			ans = ''
			start = m * i + 1
			diff = m + n - i
			for j in range(m):
				d = start + diff * j
				ans = ans + ' ' + str(d)
			print(ans.strip())
	elif m > n:
		for i in range(n):
			ans = ''
			start = (m + n) * i + 1
			diff = n - i
			for j in range(m):
				d = start + diff * j
				ans = ans + ' ' + str(d)
			print(ans.strip())
	else:
		for i in range(0, n):
			ans = ''
			start = 1 + 2 * i
			diff = 1 + 2 * i
			for j in range(0, m):
				d = start + diff * j
				ans = ans + ' ' + str(d)
			print(ans.strip())


import math
from collections import Counter
from sys import maxsize
ints = lambda : list(map(int, input().split()))
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
m = 10 ** 9 + 7
inp = lambda : int(input())

def complementary():
	d = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
	n = inp()
	s = input()
	for x in s:
		if x in d:
			print(d[x], end='')
	print()

def get_max_count(arr):
	d = {}
	for x in arr:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return max(d.values())

def make_all_equal():
	n = inp()
	arr = ints()
	max_count = get_max_count(arr)
	print(n - max_count)

def count_acs():
	p = inp()
	n_hundred = p // 100
	n_single = p % 100
	if n_hundred + n_single <= 10:
		print(n_hundred + n_single)
	else:
		print(-1)

def is_prime(n):
	for x in range(2, int(n ** 0.5)):
		if n % x == 0:
			return False
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def strong_elements():

	def get_prime_count(arr):
		count = 0
		for x in arr:
			if is_prime(x):
				count += 1
			if count == 2:
				return count
		return count
	n = inp()
	arr = ints()
	co_primes = 0
	gcd_of_n = arr[0]
	prev_gcd = gcd_of_n
	for x in arr:
		gcd_of_n = gcd(x, gcd_of_n)
		if gcd_of_n == 1:
			co_primes += 1
			gcd_of_n = prev_gcd
		if co_primes == 2:
			print(0)
			return
		prev_gcd = gcd_of_n
	if co_primes == 1:
		print(2)
	else:
		print(n)

def bubble_sort(arr, n, _max):
	for i in range(n - 1):
		flag = 0
		for j in range(n - i - 1):
			if arr[j] > arr[j + 1]:
				if arr[j] + arr[j + 1] <= _max:
					flag = 1
					(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
				else:
					return 'no'
		if not flag:
			return 'yes'
	return 'yes'

def reverse_sort():
	(n, x) = ints()
	A = ints()
	for i in range(len(A)):
		min_idx = i
		for j in range(i + 1, len(A)):
			if A[min_idx] > A[j]:
				min_idx = j
		if A[i] + A[min_idx] <= x or A[i] == A[min_idx]:
			(A[i], A[min_idx]) = (A[min_idx], A[i])
		else:
			return 'no'
	return 'yes'

def AP():
	(n, m) = ints()
	for row in range(n):
		if m == n:
			a = 2 * row + 1
			arr = [a * col for col in range(1, m + 1)]
		elif m < n:
			initial = row + 1
			diff = m + initial
			arr = [initial + col * diff for col in range(m)]
		else:
			initial = (n + 1) * row + 1
			diff = row + 1
			arr = [initial + col * diff for col in range(m)]
		print(*arr)
for _ in range(inp()):
	AP()