Let a be a matrix of size r × c containing positive integers, not necessarily distinct. Rows of the matrix are numbered from 1 to r, columns are numbered from 1 to c. We can construct an array b consisting of r + c integers as follows: for each i ∈ [1, r], let b_i be the greatest common divisor of integers in the i-th row, and for each j ∈ [1, c] let b_{r+j} be the greatest common divisor of integers in the j-th column. 

We call the matrix diverse if all r + c numbers b_k (k ∈ [1, r + c]) are pairwise distinct. 

The magnitude of a matrix equals to the maximum of b_k.

For example, suppose we have the following matrix:

\begin{pmatrix} 2 & 9 & 7\\\ 4 & 144 & 84 \end{pmatrix} 

We construct the array b:

  1. b_1 is the greatest common divisor of 2, 9, and 7, that is 1; 
  2. b_2 is the greatest common divisor of 4, 144, and 84, that is 4; 
  3. b_3 is the greatest common divisor of 2 and 4, that is 2; 
  4. b_4 is the greatest common divisor of 9 and 144, that is 9; 
  5. b_5 is the greatest common divisor of 7 and 84, that is 7. 



So b = [1, 4, 2, 9, 7]. All values in this array are distinct, so the matrix is diverse. The magnitude is equal to 9.

For a given r and c, find a diverse matrix that minimises the magnitude. If there are multiple solutions, you may output any of them. If there are no solutions, output a single integer 0. 

Input

The only line in the input contains two space separated integers r and c (1 ≤ r,c ≤ 500) — the number of rows and the number of columns of the matrix to be found.

Output

If there is no solution, output a single integer 0.

Otherwise, output r rows. The i-th of them should contain c space-separated integers, the j-th of which is a_{i,j} — the positive integer in the i-th row and j-th column of a diverse matrix minimizing the magnitude.

Furthermore, it must hold that 1 ≤ a_{i,j} ≤ 10^9. It can be shown that if a solution exists, there is also a solution with this additional constraint (still having minimum possible magnitude).

Examples

Input


2 2


Output


4 12
2 9

Input


1 1


Output


0

Note

In the first example, the GCDs of rows are b_1 = 4 and b_2 = 1, and the GCDs of columns are b_3 = 2 and b_4 = 3. All GCDs are pairwise distinct and the maximum of them is 4. Since the GCDs have to be distinct and at least 1, it is clear that there are no diverse matrices of size 2 × 2 with magnitude smaller than 4.

In the second example, no matter what a_{1,1} is, b_1 = b_2 will always hold, so there are no diverse matrices.

Difficulty: MEDIUM
Tags: Greedy algorithms

Number theory

Mathematics

Constructive algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		(r, c) = ria()
		R = []
		C = []
		z = []
		for i in range(r):
			z.append([1] * c)
		for i in range(c):
			C.append(i + 1)
		for i in range(r):
			R.append(c + i + 1)
		for i in range(r):
			for j in range(c):
				z[i][j] = R[i] * C[j]
		if r == 1 and c == 1:
			print(0)
		elif r == 1 and c > 1:
			for i in range(c):
				print(i + 2, end=' ')
		else:
			for i in z:
				print(*i)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_str():
	return list(sys.stdin.readline().split())

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
(H, W) = inpl()
if H == 1 and W == 1:
	ans = [[0]]
else:
	if W == 1:
		Xs = [1]
		Ys = [i for i in range(2, 2 + H)]
	else:
		Xs = [i for i in range(2, W + 2)]
		Ys = [1] + [i for i in range(W + 2, W + 2 + H - 1)]
	ans = [[0] * W for _ in range(H)]
	for y in range(H):
		for x in range(W):
			ans[y][x] = Xs[x] * Ys[y]
arr = []
for x in range(W):
	tmp = ans[0][x]
	for y in range(H):
		tmp = gcd(tmp, ans[y][x])
	arr.append(tmp)
for y in range(H):
	tmp = ans[y][0]
	for x in range(W):
		tmp = gcd(tmp, ans[y][x])
	arr.append(tmp)
assert H + W == len(set(arr)) or H + W == 2, 'ERROR'
for a in ans:
	print(' '.join(map(str, a)))


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
	quit()
elif r == 1 and c != 1:
	arr = [2, 3]
	c -= 2
	start = 4
	while c != 0:
		arr.append(start)
		start += 1
		c -= 1
	print(' '.join((str(k) for k in arr)))
	quit()
elif r != 1 and c == 1:
	arr = [2, 3]
	r -= 2
	start = 4
	while r != 0:
		arr.append(start)
		start += 1
		r -= 1
	for x in arr:
		print(x)
	quit()
arr = [[0] * c for i in range(r)]
div = r + c
for i in range(r):
	for j in range(c):
		arr[i][j] = (div - i) * (j + 1)
for x in arr:
	print(' '.join((str(k) for k in x)))


def Input():
	tem = input().split()
	ans = []
	for it in tem:
		ans.append(int(it))
	return ans
(n, m) = Input()
if n == 1 and m == 1:
	print(0)
elif n == 1 or m == 1:
	if n == 1:
		print(2, end='')
		for i in range(1, m):
			print(' ', i + 2, end='')
		print()
	else:
		for i in range(n):
			print(i + 2)
else:
	flag = False
	if n >= m:
		(n, m) = (m, n)
		flag = True
	ans = [[0] * m for i in range(n)]
	for i in range(m):
		ans[0][i] = i + 2
	for i in range(1, n):
		for j in range(m):
			ans[i][j] = (m + 1 + i) * ans[0][j]
	if flag:
		for i in range(m):
			print(ans[0][i], end='')
			for j in range(1, n):
				print(' ', ans[j][i], end='')
			print()
	else:
		for i in range(n):
			print(ans[i][0], end='')
			for j in range(1, m):
				print(' ', ans[i][j], end='')
			print()


import sys
import math
(r, c) = map(int, input().split())
arr = []
cur = c
if r == 1 and c == 1:
	arr = [[0]]
elif r == 1:
	arr.append([])
	for i in range(c):
		arr[-1].append(i + 2)
elif c == 1:
	for i in range(r):
		arr.append([i + 2])
for i in range(r):
	arr.append([])
	for j in range(c):
		arr[-1].append((cur + 1) * (j + 1))
	cur += 1
for i in range(r):
	print(*arr[i])


a = [int(i) for i in input().split()]
r = a[0]
c = a[1]
if r == 1 and c == 1:
	print(0)
elif c != 1:
	for i in range(1, r + 1):
		for j in range(1, c + 1):
			print(i * (j + r), end=' ')
		print()
else:
	for i in range(2, 2 + r):
		print(i)


(r, c) = map(int, input().split())
l = [[0] * c for i in range(r)]
if r == 1 and c == 1:
	print(0)
	exit()
if r == 1 or c == 1:
	for i in range(2, r + c + 1):
		print(i, end=' ')
	exit()
for i in range(r):
	ans = (r + 1) * (i + 1)
	for j in range(c):
		l[i][j] = ans
		ans += i + 1
for i in range(r):
	for j in range(c):
		print(l[i][j], end=' ')
	print()


import sys
input = sys.stdin.readline
for _ in range(1):
	(r, c) = map(int, input().split())
	if r == 1 and c == 1:
		print(0)
		continue
	if r == 1:
		mat = []
		for i in range(2, c + 2):
			mat.append(i)
		print(*mat)
		continue
	if c == 1:
		mat = []
		for i in range(2, r + 2):
			o = []
			o.append(i)
			mat.append(o)
		for i in mat:
			print(*i)
		continue
	mat = []
	for i in range(1, r + 1):
		o = []
		for j in range(1, c + 1):
			o.append(i * (j + r))
		mat.append(o)
	for i in mat:
		print(*i)


(r, c) = list(map(int, input().split()))
if r == 1 and c == 1:
	print(0)
elif c > 1:
	core = [r + i + 1 for i in range(c)]
	ans = core[:]
	for i in range(r):
		print(' '.join(map(str, ans)))
		for j in range(c):
			ans[j] = ans[j] + core[j]
else:
	for i in range(r):
		print(i + 2)


inp = input
(a, b) = map(int, inp().strip().split(' '))
if a == 1 and b == 1:
	print(0)
elif a == 1 and b == 2:
	print('2 3')
elif a == 2 and b == 1:
	print('2')
	print('3')
else:
	row = [2]
	col = [2, 3]
	if a == 1:
		row = [2, 3]
		col = [2]
	mi = min(a, b)
	while len(row) < mi:
		row.append(row[-1] + 2)
	while len(col) < mi:
		col.append(col[-1] + 2)
	if row[-1] % 2 == 0 and len(row) < b:
		(row, col) = (col, row)
	elif col[-1] % 2 == 0 and len(col) < a:
		(row, col) = (col, row)
	nex = max(row[-1], col[-1]) + 1
	while len(row) < b:
		row.append(nex)
		nex += 1
	while len(col) < a:
		col.append(nex)
		nex += 1
	ans = [[0 for i in range(b)] for j in range(a)]
	ans[0] = row
	for i in range(1, a):
		ans[i][0] = col[i]
	for i in range(1, a):
		for j in range(1, b):
			ans[i][j] = ans[0][j] * ans[i][0]
	for i in ans:
		print(*i)


(n, m) = map(int, input().split())
lis = [[0] * m for i in range(n)]
if n == 1 and m == 1:
	print(0)
elif n == 1:
	lis = [i for i in range(2, 2 + m, 1)]
	print(*lis)
elif m == 1:
	for i in range(1, n + 1):
		print(i + 1)
else:
	for i in range(n):
		for j in range(m):
			lis[i][j] = (i + 1) * (n + 1 + j)
	for i in lis:
		print(*i)


(r, c) = list(map(int, input().rstrip().split()))
if r == 1:
	if c == 1:
		print(0)
	else:
		for i in range(1, c + 1):
			print(i + 1, end=' ')
		print()
elif c == 1:
	for i in range(1, r + 1):
		print(i + 1)
else:
	for j in range(1, r + 1):
		temp = 1
		if j != 1:
			temp = c + 2 + (j - 2)
		for i in range(1, c + 1):
			print(temp * (i + 1), end=' ')
		print()


for _ in range(1):
	(n, m) = map(int, input().split())
	if n == 1 and m == 1:
		print(0)
		break
	if n == 1:
		for i in range(1, m + 1):
			print(n + i, end=' ')
		print()
		break
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			print((m + i) * j, end=' ')
		print()


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def verify(r, c, mat):
	val = []
	for i in range(r):
		g = mat[i][0]
		for j in range(1, c):
			g = gcd(g, mat[i][j])
		val.append(g)
	for j in range(c):
		g = mat[0][j]
		for i in range(1, r):
			g = gcd(g, mat[i][j])
		val.append(g)
	print(val)
(r, c) = map(int, input().split())
if r == c == 1:
	print(0)
elif c == 1:
	print(' '.join(map(str, range(2, r + 2))))
elif r == 1:
	for i in range(2, c + 2):
		print(i)
else:
	mat = [[1] * c for _ in range(r)]
	cur = 1
	for i in range(r):
		for j in range(c):
			mat[i][j] *= cur
		cur += 1
	for j in range(c):
		for i in range(r):
			mat[i][j] *= cur
		cur += 1
	for i in range(r):
		print(' '.join(map(str, mat[i])))


(r, c) = map(int, input().split())
for i in range(10 ** 5):
	pass
if r == 1 or c == 1:
	if r == 1 and c == 1:
		print(0)
	else:
		x = [i for i in range(2, r + c + 1)]
		if r == 1:
			print(' '.join(map(str, x)))
		else:
			for i in x:
				print(i)
else:
	a = []
	c2 = {}
	c1 = {}
	i = 1
	cnt = 0
	while cnt < r + c:
		if i & 1:
			a.append(i)
			cnt += 1
		elif cnt < r + c:
			if i // 2 not in c1:
				c1[i] = True
				a.append(i)
				cnt += 1
			elif i // 2 not in c2:
				c2[i] = True
				a.append(i)
				cnt += 1
		i += 1
	aa = []
	bb = []
	b = {}
	for i in a:
		if i not in b:
			aa.append(i)
			b[i] = True
		else:
			bb.append(i)
	while len(aa) - len(bb) > r - c:
		k = aa[-1]
		aa.pop()
		bb.append(k)
	aa = sorted(aa)
	bb = sorted(bb)
	ans = [[0 for i in range(c)] for j in range(r)]
	for i in range(r):
		for j in range(c):
			ans[i][j] = aa[i] * bb[j]
	for i in ans:
		print(' '.join(map(str, i)))


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(r, c) = Neo()
(a, b) = (1, 1 + r)
if (r, c) == (1, 1):
	print(0)
	exit()
if r == 1:
	print(*list(range(2, c + 2)))
	exit()
if c == 1:
	for i in range(2, r + 2):
		print(i)
	exit()
for i in range(r):
	k = b
	A = []
	for j in range(c):
		t = a * k // math.gcd(a, k)
		A.append(t)
		k += 1
	a += 1
	print(*A)


(n, m) = tuple(map(int, input().split()))
a = [[-1 for i in range(m + 1)] for j in range(n + 1)]
if n == 1 and m == 1:
	print(0)
else:
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			if m != 1:
				a[i][j] = i * (n + j)
			else:
				a[i][j] = (i + 1) * j
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			print(a[i][j], end=' ')
		print()


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
	exit()
arr = [[] for i in range(r)]
if r <= c:
	s = set()
	x = 4
	arr[0].append(2)
	s.add(2)
	for i in range(1, r):
		s.add(x)
		arr[i].append(x)
		x += 2
	x = 3
	for i in range(1, c):
		if x not in s:
			arr[0].append(x)
			s.add(x)
			x += 1
		while x in s:
			x += 1
	for i in range(1, r):
		for j in range(1, c):
			arr[i].append(arr[i][0] * arr[0][j])
	for i in range(r):
		print(*arr[i])
else:
	s = set()
	x = 4
	arr[0].append(2)
	s.add(2)
	for i in range(1, c):
		arr[0].append(x)
		s.add(x)
		x += 2
	x = 3
	for i in range(1, r):
		if x not in s:
			arr[i].append(x)
			s.add(x)
			x += 1
		while x in s:
			x += 1
	for i in range(1, r):
		for j in range(1, c):
			arr[i].append(arr[i][0] * arr[0][j])
	for i in range(r):
		print(*arr[i])


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
(r, c) = inputnums()
matrix = [[0 for j in range(c)] for i in range(r)]
if c == 1 and r == 1:
	print(0)
elif r >= c:
	for i in range(r):
		matrix[i][0] = i + 2
		if c > 1:
			matrix[i][1] = matrix[i][0] * (r + 2)
			for j in range(2, c):
				matrix[i][j] = matrix[i][j - 1] + i + 2
	for i in range(r):
		print(*matrix[i])
else:
	for i in range(c):
		matrix[0][i] = i + 2
		if r > 1:
			matrix[1][i] = matrix[0][i] * (c + 2)
			for j in range(2, r):
				matrix[j][i] = matrix[j - 1][i] + i + 2
	for i in range(r):
		print(*matrix[i])


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif c >= r:
	for i in range(1, r + 1):
		for j in range(1, c + 1):
			print(i * (r + j), end=' ')
		print('')
elif c < r:
	for i in range(1, r + 1):
		for j in range(1, c + 1):
			print(j * (c + i), end=' ')
		print('')


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


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
	exit()
ans = [[0] * c for _ in range(r)]
if r == 1:
	for x in range(c):
		ans[0][x] = x + 2
	print(*ans[0])
	exit()
if c == 1:
	for y in range(r):
		ans[y][0] = y + 2
	for l in ans:
		print(*l)
	exit()
row = [1, 4]
col = [2, 3]
n = 5
for i in range(3, r + 1):
	row.append(n)
	n += 1
for i in range(3, c + 1):
	col.append(n)
	n += 1
for (y, rv) in enumerate(row):
	for (x, cv) in enumerate(col):
		ans[y][x] = rv * cv
for l in ans:
	print(*l)


import sys
import collections
from collections import Counter
import itertools
import math
import timeit
input = sys.stdin.readline

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
(r, c) = mi()
res = [[0] * c for _ in range(r)]
if r == c == 1:
	exit(print(0))
if c >= r:
	for i in range(c):
		res[0][i] = r + i + 1 if r > 1 else i + 2
	for i in range(1, r):
		for j in range(c):
			res[i][j] = res[0][j] * (i + 1)
else:
	for i in range(r):
		res[i][0] = c + i + 1 if r > 1 else i + 2
	for i in range(r):
		for j in range(1, c):
			res[i][j] = res[i][0] * (j + 1)
for i in res:
	prr(i, ' ')


import math
(n, m) = map(int, input().strip().split(' '))
if n == 1 and m == 1:
	print(0)
elif m == 1:
	for j in range(n):
		print(j + 2)
elif n == 1:
	for j in range(m):
		print(j + 2, end=' ')
else:
	l = []
	for j in range(m):
		l.append(j + 2)
		print(j + 2, end=' ')
	print()
	p = m + 1
	for j in range(n - 1):
		p += 1
		for j1 in range(m):
			k1 = p * l[j1] // math.gcd(p, l[j1])
			print(k1, end=' ')
		print()


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif c == 1:
	for i in range(r):
		print(i + 2)
else:
	for j in range(r):
		A = []
		if j == 0:
			k = 1
		else:
			k = c + 1 + j
		for i in range(c):
			A.append((i + 2) * k)
		print(' '.join(list(map(str, A))))


inp = input()
inp_arr = inp.split(' ')
r = int(inp_arr[0])
c = int(inp_arr[1])
if r == 1 and c == 1:
	print(0)
elif r <= c:
	arr = [[] for i in range(r)]
	for i in range(r):
		for j in range(c):
			arr[i].append(str((i + 1) * (j + 1 + r)))
	for i in arr:
		out = ' '.join(i)
		print(out)
else:
	arr = [[] for i in range(r)]
	for i in range(r):
		for j in range(c):
			arr[i].append(str((c + i + 1) * (j + 1)))
	for i in arr:
		out = ' '.join(i)
		print(out)


import sys
import math
from collections import defaultdict, Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	(r, c) = map(int, input().split())
	if r == c == 1:
		print(0)
		continue
	if c == 1:
		for j in range(r):
			print(j + 2)
	else:
		d = defaultdict(dict)
		for j in range(1, r + c + 1):
			cur = j
			if j % 2 == 0:
				j //= 2
				d[cur][2] = 1
				while j % 2 == 0:
					j //= 2
					d[cur][2] += 1
			for k in range(3, int(math.sqrt(j)) + 1, 2):
				if j % k == 0:
					j //= k
					d[cur][k] = 1
					while j % k == 0:
						j //= k
						d[cur][k] += 1
			if j > 2:
				d[cur][j] = 1
		l = [[0] * c for j in range(r)]
		for j in range(c):
			for k in range(r):
				l[k][j] = j + 2
				ind = c + k + 2
				for jj in d[ind]:
					if d[ind][jj] > d[l[k][j]].get(jj, 0):
						l[k][j] *= pow(jj, d[ind][jj] - d[l[k][j]].get(jj, 0))
		for j in range(r):
			print(*l[j])


(p, q) = list(map(int, input().split()))
a = []
if p == 1 and q == 1:
	print(0)
elif p == 1:
	for i in range(q):
		print(2 + i, end=' ')
elif q == 1:
	for i in range(p):
		print(2 + i)
else:
	for i in range(q):
		a.append(2 + i)
	b = []
	k = 2 + q
	b.append(a)
	for i in range(p - 1):
		c = []
		for j in range(q):
			c.append(a[j] * k)
		k += 1
		b.append(c)
	for i in b:
		print(*i)


def transpose(l1, l2):
	l2 = [[row[i] for row in l1] for i in range(len(l1[0]))]
	return l2
(r1, c1) = map(int, input().split())
r = min(r1, c1)
c = max(r1, c1)
arr1 = []
if r == 1 and c == 1:
	print(0)
else:
	arr = [i for i in range(2, 2 + c)]
	arr1.append(arr)
	for j in range(r - 1):
		l = []
		l = [i * (c + 2 + j) for i in arr]
		arr1.append(l)
	if c1 > r1:
		for i in arr1:
			print(*i)
	else:
		for i in transpose(arr1, []):
			print(*i)


(r, c) = map(int, input().split())
flag = r > c
(r, c) = sorted([r, c])
if r == c == 1:
	print(0)
else:
	A = [[0 for _ in range(c + 1)] for _ in range(r + 1)]
	for i in range(1, r + 1):
		for j in range(r + 1, r + c + 1):
			A[i][j - r] = i * j
	if not flag:
		for i in range(1, r + 1):
			for j in range(1, c + 1):
				print(A[i][j], end=' ')
			print()
	else:
		for i in range(1, c + 1):
			for j in range(1, r + 1):
				print(A[j][i], end=' ')
			print()


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif r == 1:
	a = range(2, c + 2)
	print(' '.join(map(str, a)))
elif c == 1:
	for i in range(2, r + 2):
		print(i)
else:
	a = range(2, c + 2)
	print(' '.join(map(str, a)))
	for i in range(r - 1):
		b = map(lambda x: x * (c + 2 + i), a)
		print(' '.join(map(str, b)))


def find(r, c):
	res = []
	if r == c and r == 1:
		res.append([0])
		return res
	elif c == 1:
		for i in range(2, r + 2):
			res.append([i])
		return res
	for i in range(1, r + 1):
		temp = []
		for j in range(r + 1, r + c + 1):
			temp.append(i * j)
		res.append(temp)
	return res
(r, c) = map(int, input().split())
result = find(r, c)
for i in result:
	print(*i)


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif r == 1:
	print(*range(2, c + 2))
elif c == 1:
	for i in range(2, r + 2):
		print(i)
else:
	ans = [[0] * c for _ in range(r)]
	for i in range(r):
		for j in range(c):
			ans[i][j] = (i + c + 1) * (j + 1)
	for row in ans:
		print(*row)


import math as m
(r, c) = map(int, input().split())
(ref, ref1) = (r, c)
if r >= c:
	r1 = r
	c1 = c
else:
	r1 = c
	c1 = r
if r == 1 and c == 1:
	print(0)
	exit(0)
(r, c) = (min(r, c), max(r, c))
row = [[] for i in range(c)]
f = set()
for i in range(1, min(r, c) + 1):
	row[0].append(2 * i)
	f.add(2 * i)
tes = 1
for i in range(2, r + c + 1):
	if i not in f:
		f.add(i)
		row[tes].append(i)
		tes += 1
for i in range(1, c):
	for j in range(1, r):
		lc = row[i][0] * row[0][j]
		row[i].append(lc)
if r1 == ref1:
	for i in range(r):
		for j in range(c):
			print(row[j][i], end=' ')
		print()
else:
	for i in row:
		print(*i)


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif c != 1:
	ans = []
	for i in range(r):
		ans.append([0] * c)
	for j in range(c):
		ans[0][j] = j + 2
	now = c + 1
	for i in range(1, r):
		now += 1
		for j in range(c):
			ans[i][j] = now * ans[0][j]
	for i in range(r):
		for j in range(c):
			print(ans[i][j], end=' ')
		print()
else:
	for i in range(r):
		print(i + 2)


(r, c) = map(int, input().split())
l = [i for i in range(2, c + 2)]
if r == 1 and c == 1:
	print(0)
	exit()
elif r == 1:
	for i in range(2, c + 2):
		print(i, end=' ')
	exit()
elif c == 1:
	for i in range(2, r + 2):
		print(i)
	exit()
ans = [l]
for j in range(1, r):
	temp = []
	for k in range(c):
		temp.append((c + j + 1) * l[k])
	ans.append(temp)
for i in range(r - 1, -1, -1):
	print(*ans[i])


(r, c) = map(int, input().split())
ans = [[0] * c for i in range(r)]
if r == 1 and c == 1:
	print(0)
	exit()
elif r == 1 or c == 1:
	num = 2
	for i in range(r):
		for j in range(c):
			ans[i][j] = num
			num += 1
else:
	for i in range(r):
		for j in range(c):
			ans[i][j] = (i + 1) * (r + j + 1)
for tmp in ans:
	print(*tmp)


(r, c) = map(int, input().split())
if r == c and r == 1:
	print(0)
elif r == 1 or c == 1:
	curr = 2
	for j in range(r):
		for k in range(c):
			print(curr, '', end='')
			curr += 1
		print()
else:
	for i in range(r):
		for j in range(c):
			print((j + 1 + r) * (i + 1), '', end='')
		print()


import math
import os
import sys
input = lambda : sys.stdin.readline().strip('\r\n')

def cin():
	return sys.stdin.readline().strip('\r\n')

def fora():
	return list(map(int, sys.stdin.readline().strip().split()))

def string():
	return sys.stdin.readline().strip()

def cout(ans):
	sys.stdout.write(str(ans))

def endl():
	sys.stdout.write(str('\n'))

def ende():
	sys.stdout.write(str(' '))

def main():
	(r, c) = map(int, cin().split())
	if r == 1 and c == 1:
		cout(0)
	elif r == 1 or c == 1:
		if r == 1:
			j = 2
			for i in range(c):
				cout(j)
				ende()
				j += 1
		else:
			j = 2
			for i in range(r):
				cout(j)
				endl()
				j += 1
	else:
		for i in range(1, r + 1):
			for j in range(1, c + 1):
				cout(i * (j + r))
				ende()
			endl()
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(r, c) = map(int, input().split())
if r == 1 and c == 1:
	matr = [[0]]
elif r <= c:
	matr = [[0 for b in range(c)] for s in range(r)]
	matr[0] = [r + s for s in range(1, c + 1)]
	for s in range(1, r):
		for b in range(c):
			matr[s][b] = matr[0][b] * (s + 1)
else:
	(r, c) = (c, r)
	matr = [[0 for b in range(c)] for s in range(r)]
	matr[0] = [r + s for s in range(1, c + 1)]
	for s in range(1, r):
		for b in range(c):
			matr[s][b] = matr[0][b] * (s + 1)
	trans = [[matr[j][i] for j in range(len(matr))] for i in range(len(matr[0]))]
	matr = trans
for s in range(len(matr)):
	print(*matr[s])


(a, b) = map(int, input().split())
if [a, b] == [1, 1]:
	print(0)
else:
	if a > b:
		p = b
		q = 0
	else:
		p = 0
		q = a
	for i in range(a):
		ans = []
		for j in range(b):
			ans.append(str((p + i + 1) * (q + j + 1)))
		print(' '.join(ans))


import sys
readline = sys.stdin.readline
(H, W) = map(int, readline().split())
if H == W == 1:
	print(0)
elif H == 1:
	print(*list(range(2, W + 2)))
elif W == 1:
	print('\n'.join(map(str, list(range(2, H + 2)))))
else:
	G = [[h * (H + w) for w in range(1, W + 1)] for h in range(1, H + 1)]
	for g in G:
		print(*g)


from sys import stdin, stdout
(r, c) = map(int, stdin.readline().split())
if r == 1 and c == 1:
	stdout.write('0\n')
else:
	(base, mult) = (None, None)
	if c < r:
		base = [x for x in range(1, c + 1)]
		mult = [x for x in range(c + 1, r + c + 1)]
	else:
		base = [x for x in range(r + 1, r + c + 1)]
		mult = [x for x in range(1, r + 1)]
	for m in mult:
		for b in base:
			stdout.write('{} '.format(m * b))
		stdout.write('\n')


(row, col) = map(int, input().split())
if row == 1 and col == 1:
	print(0)
elif col == 1:
	for i in range(2, row + 2):
		print(i)
else:
	for i in range(1, row + 1):
		for j in range(col):
			print((row + 1) * i + j * i, end=' ')
		print('')


(n, m) = (int(i) for i in input().split())
if n == 1 and m == 1:
	print(0)
elif m == 1 or n == 1:
	for i in range(n):
		for j in range(m):
			print(max(i + 2, j + 2), end=' ')
else:
	for i in range(n):
		for j in range(m):
			print((m + n - i) * (j + 1), end=' ')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def construct_matrix(columns, rows):
	for r in rows:
		for c in columns:
			print(r * c // gcd(c, r), end=' ')
		print()

def main(r, c):
	if r == c == 1:
		print(0)
		return
	a = range(1, c + r + 1)
	(rows, columns) = (a[:r], a[r:]) if r <= c else (a[c:], a[:c])
	construct_matrix(columns, rows)
(r, c) = map(int, input().split())
main(r, c)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write

def exit(*arg):
	print(*arg)
	sys.exit()

def main():
	(r, c) = map(int, readline().split())
	if r == 1 and c == 1:
		exit(0)
	ans = [[0] * c for i in range(r)]
	if c == 1:
		for i in range(r):
			ans[i][0] = i + 2
	else:
		for i in range(r):
			for j in range(c):
				ans[i][j] = (i + 1) * (r + j + 1)
	for i in range(r):
		print(*ans[i])
	return
main()


(r, c) = map(int, input().split())
t = r + c
if r == 1:
	if c == 1:
		print(0)
	else:
		for x in range(c):
			print(t, end=' ')
			t -= 1
else:
	for x in range(r):
		k = 1
		for y in range(c):
			print(t * k, end=' ')
			k += 1
		print()
		t -= 1


(r, c) = list(map(int, input().split()))
gcds = [i for i in range(1, r + c + 1)]
arr = []
if r == 1 and c == 1:
	print(0)
	exit()
if r == 1:
	print(*[i + 2 for i in range(c)])
	exit()
elif c == 1:
	for i in range(r):
		print(i + 2)
	exit()
for _ in range(r):
	arr.append([0] * c)
row = []
col = []
for i in range(r):
	row.append(gcds[i])
for i in range(c):
	col.append(gcds[r + c - 1 - i])
for i in range(r):
	for j in range(c):
		arr[i][j] = (i + 1) * (r + j + 1)
for i in arr:
	print(*i)


(r, c) = [int(x) for x in input().split()]
x = r + c
res = []
i = 0
if r == 1 and c == 1:
	print(0)
elif r == 1:
	for j in range(c):
		print(j + 2, end=' ')
elif c == 1:
	for i in range(r):
		print(i + 2)
else:
	while i < r:
		s = x
		delta = [s]
		for k in range(1, c):
			s = (k + 1) * x
			delta.append(s)
		x -= 1
		i += 1
		res.append(delta)
	for k in range(r):
		for j in range(c):
			print(res[k][j], end=' ')
		print('')


import os
import sys

def main():
	(R, C) = read_ints()
	A = solve(R, C)
	if A is None:
		print('0')
	else:
		for a in A:
			print(*a)

def solve(R, C):
	if (R, C) == (1, 1):
		return None
	if C == 1:
		return [[i] for i in range(2, R + 2)]
	if R == 1:
		return [list(range(2, C + 2))]
	A = []
	for i in range(1, R + 1):
		A.append([i * j for j in range(R + 1, R + C + 1)])
	return A
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
(r, c) = multi_int_input()
if r == 1 and c == 1:
	print(0)
elif r == 1 and c > 1:
	base = 2
	result = [base + i for i in range(c)]
	print(*result)
elif r > 1 and c == 1:
	base = 2
	for i in range(r):
		print(base + i, end=' ')
	print()
else:
	result_row = []
	for i in range(1, r + 1):
		result_row.append(i)
	result_col = []
	for i in range(r + 1, r + c + 1):
		result_col.append(i)
	final = []
	for i in range(r):
		final.append([])
		for j in range(c):
			final[i].append(0)
	for i in range(r):
		for j in range(c):
			final[i][j] = result_row[i] * result_col[j]
	for i in range(r):
		for j in range(c):
			print(final[i][j], end=' ')
		print()


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from collections import defaultdict as dd
(r, c) = I()
if 1 == r == c:
	print(0)
	exit()
swap = 0
if r > c:
	swap = 1
	(r, c) = (c, r)
ans = [[1] * c for i in range(r)]
for i in range(r):
	ans[i][0] = i + 1
for i in range(1, c):
	ans[0][i] = r + i
for i in range(1, r):
	for j in range(1, c):
		ans[i][j] = ans[i][0] * ans[0][j]
for i in range(r):
	ans[i][0] *= r + c
if not swap:
	for i in ans:
		print(*i)
else:
	t = [[0] * 501 for i in range(501)]
	for i in range(r):
		for j in range(c):
			t[j][i] = ans[i][j]
	for i in range(c):
		for j in range(r):
			print(t[i][j], end=' ')
		print()


(n, m) = map(int, input().split())
if n + m < 3:
	print(0)
	exit(0)
a = max(n, m) + 2
b = min(n, m)
c = list(range(2, a))
d = [1] + list(range(a, a + b - 1))
if n < m:
	(c, d) = (d, c)
for i in c:
	print(*[x * i for x in d])


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif c == 1:
	for d in range(r):
		print(d + 2)
else:
	base = [k for k in range(2, c + 2)]
	str_base = [str(i) for i in base]
	print(' '.join(str_base))
	counter = base[-1]
	for j in range(r - 1):
		counter += 1
		s = [str(counter * h) for h in base]
		print(' '.join(s))


def f():
	(r, c) = map(int, input().split())
	if r == 1 and c != 1:
		for k in range(2, c + 2):
			print(k, end=' ')
		return
	if r == 0 or c == 0 or (r == 1 and c == 1):
		print(0)
		return
	ar = [[0 for k in range(c)] for p in range(r)]
	for k in range(r):
		ar[k][0] = k + 2
	for k in range(1, c):
		ar[0][k] = (r + 1 + k) * 2
	for k in range(1, r):
		for p in range(1, c):
			ar[k][p] = (r + p + 1) * ar[k][0]
	for k in range(r):
		for p in range(c):
			print(ar[k][p], end=' ')
		print()
f()


import sys
input = sys.stdin.readline
(r, c) = map(int, input().split())
import math

def lcm(x, y):
	return x * y // math.gcd(x, y)
if r == c == 1:
	print(0)
elif r <= c:
	for i in range(r):
		for j in range(c):
			print(lcm(i + 1, r + j + 1), end=' ')
		print()
else:
	for i in range(r):
		for j in range(c):
			print(lcm(j + 1, c + i + 1), end=' ')
		print()


(n, m) = (int(i) for i in input().split())
a = []
if n == 1 and m == 1:
	print(0)
elif n == 1:
	for i in range(2, m + 2):
		print(i, end=' ')
	print()
elif m == 1:
	for i in range(2, n + 2):
		print(i)
else:
	for i in range(n):
		a.append([0 for j in range(m)])
	for i in range(m):
		a[0][i] = (n + m) * (n + m - 1 - i)
	print(*a[0])
	for i in range(1, n):
		for j in range(m):
			a[i][j] = (n + m - 1 - j) * (n - 1 - (i - 1))
		print(*a[i])


import sys
from math import gcd

def rint():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().rstrip('\n')

def oint():
	return int(input())
(r, c) = rint()
if r == 1 and c == 1:
	print(0)
	exit()
flag = 0
if r > c:
	(r, c) = (c, r)
	flag = 1
cnt = r + c
m = [[1 for i in range(c)] for j in range(r)]
k = 0
for i in range(r):
	k += 1
	for j in range(c):
		m[i][j] *= k
for j in range(c):
	k += 1
	for i in range(r):
		kk = gcd(k, m[i][j])
		m[i][j] *= k // kk
if flag:
	for i in range(c):
		aa = []
		for j in range(r):
			aa.append(m[j][i])
		print(*aa)
	exit()
for i in range(r):
	print(*m[i])


(r, c) = map(int, input().rstrip().split())
if r == 1 and c == 1:
	print(0)
	exit()
mat = [[0] * c for _ in range(r)]
if c == 1:
	for i in range(r):
		mat[i][0] = i + 2
else:
	for i in range(r):
		for j in range(c):
			mat[i][j] = (r + 1) * (i + 1) + j * (i + 1)
for x in mat:
	print(*x)


import sys
import math
from collections import OrderedDict
from collections import defaultdict

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))
(r, c) = minput()
if r == 1 and c == 1:
	print(0)
elif r == 1:
	for i in range(2, c + 2):
		print(i, end=' ')
else:
	for i in range(1, r + 1):
		for j in range(1, c + 1):
			print((c + i) * j, end=' ')
		print()


def f():
	(r, c) = [int(s) for s in input().split()]
	if r >= 2 and c >= 2:
		col = list(range(c + 1, r + c + 1))
		col[0] = 1
		for i in col:
			row = [i * j for j in range(2, c + 2)]
			print(' '.join((str(s) for s in row)))
		return
	if r == 1 and c == 1:
		print(0)
		return
	if r == 1:
		print(' '.join((str(i) for i in range(2, c + 2))))
		return
	if c == 1:
		for i in range(2, r + 2):
			print(i)
f()


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())

def solve(n):
	if n % 14 >= 1 and n % 14 <= 6 and (n >= 15):
		return 'YES'
	return 'NO'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, k) = mapin()
if n == k and n == 1:
	print(0)
elif k == 1:
	for i in range(n):
		print(i + 2)
else:
	for i in range(n):
		for j in range(k):
			print((i + 1) * (j + n + 1), end=' ')
		print('')


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif r == 1:
	print(' '.join((str(i) for i in range(2, c + 2))))
else:
	matr = [[i] * c for i in range(2, r + 2)]
	for i in range(1, c):
		for j in range(r):
			matr[j][i] *= r + 1 + i
	for rw in matr:
		print(' '.join(map(str, rw)))


def main():
	(r, c) = map(int, input().split())
	if r == 1 and c == 1:
		print(0)
		return
	rev = False
	if r > c:
		rev = True
		(r, c) = (c, r)
	b = [i + 1 for i in range(r + c)]
	a = [[0 for i in range(c)] for j in range(r)]
	for i in range(r):
		for j in range(c):
			a[i][j] = b[i] * b[r + j]
	if rev:
		a = [[row[i] for row in a] for i in range(len(a[0]))]
	for i in a:
		print(*i)
	return
main()


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
(n, m) = value()
if n == 1 and m == 1:
	print(0)
elif n == 1:
	print(*[j for j in range(2, m + 2)])
else:
	j = 2
	ans = []
	for i in range(n):
		l = [j]
		for k in range(n + 2, n + m + 1):
			l += [j * k]
		ans += [l]
		j += 1
	for i in range(n):
		print(*ans[i])


(r, c) = map(int, input().split())
a = []
for i in range(r + 1):
	a.append([0] * (c + 1))
if c == r == 1:
	print(0)
elif c == 1:
	for i in range(1, r + 1):
		print(i + 1)
else:
	for i in range(1, r + 1):
		for j in range(1, c + 1):
			a[i][j] = i * (j + r)
	for i in range(1, r + 1):
		for j in range(1, c + 1):
			print(a[i][j], end=' ')
		print()


(x, y) = map(int, input().split())
if x * y == 1:
	print(0)
	exit(0)
if x == 1:
	for n in range(2, y + 2):
		print(n, end=' ')
	exit(0)
if y == 1:
	for n in range(2, x + 2):
		print(n)
	exit(0)
res = [[1 for _ in range(y)] for _ in range(x)]
for col in range(1, y + 1):
	for row in range(1, x + 1):
		res[row - 1][col - 1] *= col
for row in range(1, x + 1):
	for col in range(1, y + 1):
		res[row - 1][col - 1] *= y + row
for n in res:
	print(*n)


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif r == 1:
	for a in range(2, c + 2):
		print(a)
elif c == 1:
	for b in range(2, r + 2):
		print(b, end=' ')
else:
	mat = [[0] * c for i in range(r)]
	for row in range(r):
		for kol in range(c):
			mat[row][kol] = (row + 1) * (kol + 1 + r)
	for i in range(r):
		print(*mat[i])


from math import ceil, sqrt, log

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def main():
	(n, m) = mi()
	if n == 1 and m == 1:
		print(0)
	elif n == 1:
		for j in range(n + 1, m + 2):
			print(j, end=' ')
		print()
	elif m == 1:
		for i in range(1, n + 1):
			print(i + 1, end=' ')
			print()
	else:
		for i in range(1, n + 1):
			for j in range(n + 1, m + n + 1):
				print(i * j, end=' ')
			print()
main()


(r, c) = map(int, input().split())
mat = [[1 for i in range(r)] for i in range(c)]
if r == 1 and c == 1:
	print(0)
elif r == 1:
	mat = [0 for i in range(c)]
	for i in range(c):
		print(i + 2, end=' ')
	print('')
else:
	for i in range(r):
		mat[0][i] = i + 2
	t = r + 2
	for i in range(1, c):
		for j in range(r):
			mat[i][j] = mat[0][j] * t
		t += 1
	for i in range(r):
		for j in range(c):
			print(mat[j][i], end=' ')
		print('')


from math import ceil
from math import factorial
from collections import Counter
from operator import itemgetter
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
s = [1 for i in range(10 ** 4)]
s[0] = 0
s[1] = 0
pr = []
for i in range(2, 10 ** 4):
	if s[i] == 1:
		pr.append(i)
		for j in range(i, 10 ** 4, i):
			s[j] = 0
(n, k) = iia()
x = [0 for i in range(n)]
y = [0 for j in range(k)]
if n == 1 and k == 1:
	print(0)
else:
	m = 1
	if n != 1 and k != 1:
		for i in range(n):
			x[i] = m
			m += 1
		for j in range(k):
			y[j] = m
			m += 1
	elif n == 1 or k == 1:
		if n == 1:
			x[0] = 1
			m = 2
			for j in range(k):
				y[j] = m
				m += 1
		else:
			y[0] = 1
			m = 2
			for j in range(n):
				x[j] = m
				m += 1
	ans = [[0 for i in range(k)] for j in range(n)]
	for i in range(n):
		for j in range(k):
			ans[i][j] = x[i] * y[j]
	for i in ans:
		print(*i)


from sys import stdout
x = [int(x) for x in input().split(' ')]
r = x[0]
c = x[1]

def getAns(c, r):
	rli = []
	cli = []
	if r < c:
		rli = list(range(2, 2 * r + 2, 2))
		cli = [2] + list(range(3, 2 * r, 2))
		cli.extend(list(range(2 * r + 1, r + c + 1)))
	else:
		cli = list(range(2, 2 * c + 2, 2))
		rli = [2] + list(range(3, 2 * c, 2))
		rli.extend(list(range(2 * c + 1, r + c + 1)))
	if r == 1 and c == 1:
		print(0)
	else:
		stdout.write('2')
		for k in range(1, r):
			stdout.write(' ')
			stdout.write(str(rli[k]))
		stdout.write('\n')
		for i in range(1, c):
			stdout.write(str(cli[i]))
			for j in range(1, r):
				stdout.write(' ')
				stdout.write(str(cli[i] * rli[j]))
			if not i == c - 1:
				stdout.write('\n')
getAns(r, c)


(r, c) = map(int, input().strip().split())
if r == 1 and c == 1:
	print(0)
else:
	A = [[0 for i in range(c + 1)] for j in range(r + 1)]
	if r > c:
		for i in range(c + 1):
			A[0][i] = i
		for i in range(r + 1):
			A[i][0] = c + i
	else:
		for i in range(c + 1):
			A[0][i] = r + i
		for i in range(r + 1):
			A[i][0] = i
	for i in range(1, r + 1):
		for j in range(1, c + 1):
			A[i][j] = A[i][0] * A[0][j]
	for i in range(1, r + 1):
		print(' '.join([str(x) for x in A[i][1:]]))


(rows, cols) = map(int, input().split())
if rows == 1 and cols == 1:
	print(0)
elif rows == 1:
	q = []
	for i in range(cols):
		q.append(i + 2)
	print(*q)
elif cols == 1:
	for i in range(rows):
		print(i + 2)
else:
	q = []
	for i in range(cols):
		q.append(i + 2)
	print(*q)
	for i in range(1, rows):
		a = q[-1] + i
		p = []
		for j in range(cols):
			p.append(a * q[j])
		print(*p)


from sys import stdin
import sys
sys.setrecursionlimit(2 * 10 ** 5)
import math
(r, c) = list(map(int, stdin.readline().split()))
if r == c and r == 1:
	print(0)
	exit()
if r == 1:
	matrix = [x for x in range(2, c + 2)]
	print(*matrix)
	exit()
elif c == 1:
	matrix = [x for x in range(2, r + 2)]
	for i in range(r):
		print(matrix[i])
	exit()
col = [x for x in range(2, 2 + c)]
row = [1]
for i in range(2 + c, 2 + c + r - 1):
	row.append(i)
matrix = [[0 for x in range(c)] for y in range(r)]
for i in range(c):
	matrix[0][i] = col[i]
for i in range(1, r):
	for j in range(c):
		matrix[i][j] = row[i] * col[j]
for i in range(r):
	print(*matrix[i])


from math import floor, ceil
(r, c) = map(int, input().split())
if r == c == 1:
	print(0)
	quit()
if r == 1:
	print(' '.join(map(str, range(2, c + 2))))
	quit()
p = list(range(1, c + 1))
for i in range(c + 1, r + c + 1):
	print(' '.join(map(lambda x: str(x * i), p)))


(n, m) = map(int, input().split())
if n == 1 and m == 1:
	print(0)
elif n <= m:
	d = [[0 for i in range(m)] for _ in range(n)]
	for i in range(n):
		for j in range(m):
			d[i][j] = (i + 1) * (n - 1 + j + 2)
	for i in d:
		print(*i)
else:
	(n, m) = (m, n)
	d = [[0 for i in range(m)] for _ in range(n)]
	for i in range(n):
		for j in range(m):
			d[i][j] = (i + 1) * (n - 1 + j + 2)
	for i in range(m):
		for j in range(n):
			print(d[j][i], end=' ')
		print('')


(n, m) = map(int, input().split())
if n == 1 and m == 1:
	print(0)
	exit()
if n == 1:
	c = [1]
	r = [i for i in range(2, m + 2)]
elif m == 1:
	c = [i for i in range(2, n + 2)]
	r = [1]
else:
	r = [i for i in range(2, m + 2)]
	c = [1]
	for i in range(m + 2, n + m + 1):
		c.append(i)
ans = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
	for j in range(m):
		ans[i][j] = r[j] * c[i]
for i in range(n):
	print(*ans[i])


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
else:
	if r <= c:
		gr = [[0 for i in range(c)] for j in range(r)]
		for i in range(c):
			gr[0][i] = r + i + 1
		for i in range(1, r):
			for j in range(c):
				gr[i][j] = gr[0][j] * (i + 1)
	else:
		gr = [[0 for i in range(c)] for j in range(r)]
		for i in range(r):
			gr[i][0] = c + i + 1
		for i in range(1, c):
			for j in range(r):
				gr[j][i] = gr[j][0] * (i + 1)
	for i in range(r):
		print(*gr[i])


ar = []
for el in input().split(' '):
	ar.append(int(el))
if ar[0] == 1 and ar[1] == 1:
	print(0)
elif ar[0] == 1:
	for x in range(ar[0]):
		temp = x + 1
		tempAr = []
		for y in range(ar[1]):
			temp2 = y + 1 + ar[0]
			tempAr.append(temp * temp2)
		print(*tempAr)
elif ar[1] == 1:
	for x in range(ar[0]):
		temp = x + 1 + ar[1]
		tempAr = []
		for y in range(ar[1]):
			temp2 = y + 1
			tempAr.append(temp * temp2)
		print(*tempAr)
else:
	for x in range(ar[0]):
		temp = x + 1
		tempAr = []
		for y in range(ar[1]):
			temp2 = y + 1 + ar[0]
			tempAr.append(temp * temp2)
		print(*tempAr)


(r, c) = map(int, input().split())
if max(r, c) == 1:
	print(0)
else:
	for i in range(1, r + 1):
		for j in range(1, c + 1):
			print(i * (j + r) if r <= c else j * (i + c), end=' ')
		print()


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
(r, c) = mi()
if r == c == 1:
	print(0)
	exit()
a = [2]
(x, y) = (r, c)
if x > y:
	(x, y) = (y, x)
for i in range(3, y + x + 1, 2):
	a.append(i)
b = [i for i in range(2, x * 2 + 1, 2)]
z = b[-1] + 2
p = y - len(a)
for _ in range(p):
	a.append(z)
	z += 2
if r < c:
	p = a
	q = b
else:
	p = b
	q = a
print(*p)
for i in range(r - 1):
	for j in range(c):
		if not j:
			print(q[i + 1], end=' ')
		else:
			print(q[i + 1] * p[j], end=' ')
	print()


import sys
import math
input = sys.stdin.readline

def primes(n):
	is_prime = [True] * (n + 1)
	is_prime[0] = False
	is_prime[1] = False
	for i in range(2, int(n ** 0.5) + 1):
		if not is_prime[i]:
			continue
		for j in range(i * 2, n + 1, i):
			is_prime[j] = False
	return [i for i in range(n + 1) if is_prime[i]]
base = 10 ** 4
primes = primes(base)
(r, c) = [int(item) for item in input().split()]
if r == 1 and c == 1:
	print(0)
	exit()
if r <= c:
	row = [item for item in range(2, c + 2)]
	col = [1] + [item for item in range(2 + c, 1 + r + c)]
else:
	row = [1] + [item for item in range(2 + r, 1 + c + r)]
	col = [item for item in range(2, 2 + r)]
ans = [[0] * c for _ in range(r)]
for (i, r) in enumerate(row):
	for (j, c) in enumerate(col):
		ans[j][i] = r * c
for line in ans:
	val = 0
	for item in line:
		val = math.gcd(val, item)
	print(*line)


(r, c) = map(int, input().split())
swap = 0
if r > c:
	(r, c) = (c, r)
	swap = 1
ans = [[(i + 1) * (r + j + 1) for j in range(c)] for i in range(r)]
if r == 1 and c == 1:
	print(0)
else:
	if swap:
		for i in range(c):
			for j in range(r):
				print(ans[j][i], end=' ')
			print('')
		exit()
	for i in range(r):
		for j in range(c):
			print(ans[i][j], end=' ')
		print('')


from sys import stdin, stdout
import math
from bisect import bisect_left, bisect_right
input = lambda : stdin.readline().strip()
print = lambda s: stdout.write(s)

def lcm(a, b):
	return a * b // math.gcd(a, b)
(r, c) = map(int, input().split())
b = []
for i in range(1, r + c + 1):
	b.append(i)
mat = []
for i in range(r):
	mat.append([])
	for j in range(c):
		mat[-1].append(0)
for i in range(r):
	for j in range(c):
		mat[i][j] = lcm(b[i], b[r + j])
if r == 1 and c == 1:
	print('0\n')
elif c == 1:
	for i in range(r):
		print(str(2 + i) + '\n')
else:
	for i in range(r):
		for j in range(c):
			print(str(mat[i][j]) + ' ')
		print('\n')


(r, c) = map(int, input().split())
if r == c == 1:
	print(0)
elif c == 1:
	print('\n'.join([str(i) for i in range(2, r + 2)]))
else:
	for i in range(r):
		for j in range(c):
			print((i + 1) * (j + r + 1), end=' ')
		print()


(x, y) = map(int, input().split())
l = [0] * y
if x == 1 and y == 1:
	print(0)
elif y == 1:
	for i in range(x):
		print(i + 2)
else:
	for i in range(y):
		l[i] = i + 2
		print(l[i], end=' ')
	temp = i + 2 + 1
	print()
	for j in range(x - 1):
		for i in range(y):
			print(l[i] * temp, end=' ')
		temp += 1
		print()


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(r, c) = mints()
if r == 1 and c == 1:
	print(0)
elif c == 1:
	print(*range(2, r + 2), sep='\n')
else:
	for i in range(1, r + 1):
		print(*[i * j for j in range(r + 1, c + r + 1)])


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif r == 1 or c == 1:
	print(*[i + 2 for i in range(0, abs(r - c) + 1)])
else:
	for i in range(1, r + 1):
		row = []
		for j in range(1, c + 1):
			row.append((j + r) * i)
		print(*row)


from sys import stdin
(n, m) = map(int, stdin.readline().strip().split())
if n == 1 and m == 1:
	print(0)
	exit(0)
if m == 1:
	for i in range(n):
		print(i + 2)
	exit(0)
mt = [[-1 for i in range(m)] for j in range(n)]
for i in range(m):
	mt[0][i] = i + 2
x = mt[0][-1] + 1
for i in range(1, n):
	for j in range(m):
		mt[i][j] = x * mt[0][j]
	x += 1
for i in mt:
	print(*i)


(n, m) = map(int, input().split(' '))
arr = [[0 for i in range(m)] for j in range(n)]
if n == m == 1:
	print(0)
elif n == 1 or m == 1:
	if n == 1:
		for i in range(2, m + 2):
			print(i, end=' ')
	else:
		for i in range(2, n + 2):
			print(i)
elif n < m:
	arr[0][0] = 2
	for j in range(1, n):
		arr[j][0] = arr[j - 1][0] + 2
	for i in range(1, n):
		arr[0][i] = arr[i][0] - 1
	arr[0][n] = arr[0][n - 1] + 2
	for i in range(n + 1, m):
		arr[0][i] = arr[0][i - 1] + 1
	for i in range(1, n):
		for j in range(1, m):
			arr[i][j] = arr[0][j] * arr[i][0]
	for i in range(0, n):
		for j in range(0, m):
			print(arr[i][j], end=' ')
		print()
elif n > m:
	arr[0][0] = 2
	count = 2
	for j in range(1, m):
		arr[0][j] = arr[0][j - 1] + 2
	for i in range(1, m):
		arr[i][0] = arr[0][i] - 1
	arr[m][0] = arr[m - 1][0] + 2
	for i in range(m + 1, n):
		arr[i][0] = arr[i - 1][0] + 1
	for i in range(1, n):
		for j in range(1, m):
			arr[i][j] = arr[0][j] * arr[i][0]
	for i in range(0, n):
		for j in range(0, m):
			print(arr[i][j], end=' ')
		print()
else:
	arr[0][0] = 2
	for j in range(1, n):
		arr[j][0] = arr[j - 1][0] + 2
	for i in range(1, n):
		arr[0][i] = arr[i][0] - 1
	for i in range(1, n):
		for j in range(1, m):
			arr[i][j] = arr[0][j] * arr[i][0]
	for i in range(0, n):
		for j in range(0, m):
			print(arr[i][j], end=' ')
		print()


(r, c) = map(int, input().split())
k = [i for i in range(2, c + 2)]
if r == c == 1:
	print(0)
elif c == 1:
	for i in range(2, r + 2):
		print(i)
else:
	l = [k]
	c1 = k[-1]
	for i in range(r):
		c1 += 1
		h = []
		for j in range(c):
			h.append(k[j] * c1)
		l.append(h)
	for i in range(r):
		print(*l[i])


from math import *
(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
	exit(0)
if c == 1:
	for i in range(r):
		print(i + 2)
	exit(0)
a = [r + 1 + i for i in range(500)]
for i in range(1, r + 1):
	for j in range(c):
		print(a[j] * i, end=' ')
	print()


(n, m) = map(int, input().split())
an = []
if n == m and n == 1:
	print(0)
elif m == 1:
	for i in range(n):
		print(i + 2)
else:
	r = [1]
	c = [2, 3]
	i = 4
	while i < n + 3:
		r.append(i)
		i += 1
	while i < m + n + 3:
		c.append(i)
		i += 1
	for i in range(n):
		for j in range(m):
			print(r[i] * c[j], end=' ')
		print('\n')


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10000
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()
(r, c) = arrIN()
if r == 1 and c == 1:
	print(0)
elif r == 1:
	print(*[i for i in range(2, c + 2)])
elif c == 1:
	for i in range(2, r + 2):
		print(i)
else:
	ans = [[0 for i in range(c)] for j in range(r)]
	for i in range(c):
		ans[0][i] = i + 2
	print(*ans[0])
	for i in range(1, r):
		for j in range(c):
			ans[i][j] = ans[0][j] * (c + i + 1)
		print(*ans[i])


import sys
s = input()
v = []
v = s.split()
n = int(v[0])
m = int(v[1])
if n == 1 and m == 1:
	print(str(0))
	sys.exit()
v = [[0 for x in range(m)] for y in range(n)]
k = 0
if n == 1:
	for i in range(m):
		print(str(i + 2), end=' ')
	sys.exit()
if m == 1:
	for i in range(n):
		print(str(i + 2))
	sys.exit()
for i in range(n):
	k += 1
	for j in range(m):
		v[i][j] = k
for j in range(m):
	k += 1
	for i in range(n):
		v[i][j] *= k
for i in range(n):
	for j in range(m):
		print(str(v[i][j]), end=' ')
	print()


from math import gcd
from functools import reduce

def find_gcd(l):
	x = reduce(gcd, l)
	return x
(r, c) = [int(x) for x in input().strip().split()]
if r == 1 and c == 1:
	print(0)
elif r == 1:
	print(*[x + 2 for x in range(c)])
elif c == 1:
	for i in range(r):
		print(2 + i)
else:
	mat = [[j + 1 for i in range(c)] for j in range(r)]
	for i in range(c):
		for j in range(r):
			mat[j][i] *= r + i + 1
	for x in mat:
		print(*x)


import math
import collections
import sys

def inpu():
	return input().split(' ')

def inti(a):
	for i in range(len(a)):
		a[i] = int(a[i])
	return a

def inp():
	a = inpu()
	a = inti(a)
	return a
(r, c) = inp()
if r == 1 and c == 1:
	print(0)
	exit()
a = [[-1] * c for _ in range(r)]
if r == 1 or c == 1:
	k = 2
	for i in range(r):
		for j in range(c):
			a[i][j] = k
			k += 1
else:
	for i in range(r):
		for j in range(c):
			a[i][j] = (i + 1) * (r + 1 + j)
for ai in a:
	print(*ai)


import copy
import sys
from collections import defaultdict, Counter

def input():
	return sys.stdin.readline()

def mapi():
	return map(int, input().split())

def maps():
	return map(str, input().split())

def print(arg, *argv, end=None):
	sys.stdout.write(str(arg))
	for i in argv:
		sys.stdout.write(' ' + str(i))
	sys.stdout.write(end) if end else sys.stdout.write('\n')

def GCD(x, y):
	return GCD(y, x % y) if y else x

def modPow(x, y, p):
	(res, x) = (1, x % p)
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		(y, x) = (y >> 1, x * x % p)
	return res

def modInv(s, mod):
	return modPow(s, mod - 2, mod)

def solve():
	t = 1
	while t:
		t -= 1
		(r, c) = mapi()
		mat = [[0] * c for i in range(r)]
		if r == 1 and c == 1:
			print(0)
			continue
		elif c == 1:
			for i in range(2, r + 2):
				print(i)
			continue
		for i in range(r):
			for j in range(c):
				mat[i][j] = (i + 1) * (j + 1 + r)
		for row in mat:
			print(' '.join([str(i) for i in row]))
solve()


from copy import copy

def arr_float_inp():
	return [float(s) for s in input().split()]

def arr_int_inp():
	return [int(s) for s in input().split()]

def int_inp():
	return int(input())

def float_inp():
	return float(input())

def comp(a):
	return a[0]

def gcd(a, b):
	if b != 0:
		return gcd(b, a % b)
	else:
		return a
(r, c) = arr_int_inp()
if r == 1 and c == 1:
	print(0)
else:
	arr = [[-1 for _ in range(c)] for _ in range(r)]
	if r == 1 or c == 1:
		for i in range(r):
			for j in range(c):
				arr[i][j] = i + j + 2
	else:
		for i in range(r):
			for j in range(c):
				arr[i][j] = (j + 1) * (r + c - i)
	for row in arr:
		for el in row:
			print(el, end=' ')
		print()


def res_print(res):
	for r in res:
		for c in r:
			print(c, end=' ')
		print('\n', end='')

def make_list(m, n):
	res = []
	for r in range(1, m + 1):
		rs = []
		for c in range(m + 1, m + n + 1):
			rs.append(c * r)
		res.append(rs)
	res_print(res)

def solve():
	(m, n) = map(int, input().split())
	res = []
	if n == 1 or m == 1:
		if m == n:
			print(0)
		elif m == 1:
			make_list(m, n)
		else:
			for r in range(m):
				res.append([r + 2])
			res_print(res)
	else:
		make_list(m, n)
test = 1
while test != 0:
	solve()
	test -= 1


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	lcm = x * y // gcd(x, y)
	return lcm
(r, c) = input().split(' ')
(r, c) = (int(r), int(c))
swapped = False
if r > c:
	(r, c) = (c, r)
	swapped = True
if r == c == 1:
	print(0)
	exit(0)
ans = list((list((1 for _ in range(c))) for _ in range(r)))
for i in range(r):
	for j in range(c):
		ans[i][j] = lcm(i + 1, r + 1 + j)
if not swapped:
	for row in ans:
		for elem in row:
			print(elem, end=' ')
		print()
else:
	for j in range(c):
		for i in range(r):
			print(ans[i][j], end=' ')
		print()


import sys
from math import gcd
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict, deque
from math import log2, ceil, floor
inp = lambda : int(input())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
Judge = 0
if Judge:
	sys.stdin = open('input.in', 'r')
(r, c) = mulip()
if r == 1 and c == 1:
	print(0)
	exit(0)
if r == 1 and c > 1:
	for i in range(2, c + 2):
		print(i, end=' ')
	print()
	exit(0)
if r > 1 and c == 1:
	for i in range(2, r + 2):
		print(i)
	exit(0)
for i in range(1, r + 1):
	for j in range(r + 1, c + 1 + r):
		x = i * j
		print(x, end=' ')
	print()


from math import gcd as g
(n, m) = map(int, input().split())
if n == 1 or m == 1:
	if n == 1 and m == 1:
		print('0')
	elif n == 1:
		for i in range(2, m + 2):
			print(i, end=' ')
		print()
	else:
		for i in range(2, n + 2):
			print(i)
else:
	col = [1]
	row = [i + 2 for i in range(n)]
	for i in range(n + 2, m + n + 1):
		col.append(i)
	l = []
	for i in range(n):
		l.append([])
		for j in range(m):
			l[i].append(col[j] * row[i] // g(col[j], row[i]))
	for i in l:
		for j in i:
			print(j, end=' ')
		print()


from math import gcd

def lcm(x, y):
	return x * y // gcd(x, y)
(n, m) = map(int, input().split())
if n == m == 1:
	print(0)
elif m == 1:
	print(*range(2, n + 2), sep='\n')
else:
	for i in range(n):
		print(*(lcm(i + 1, n + j + 1) for j in range(m)))


def process(r, c):
	if r == 1 and c == 1:
		return [[0]]
	M = []
	if r <= c:
		for i in range(1, c + 1):
			row = []
			for j in range(1, r + 1):
				row.append((i + r) * j)
			M.append(row)
	else:
		for i in range(1, c + 1):
			row = []
			for j in range(1, r + 1):
				row.append(i * (j + c))
			M.append(row)
	return M
(r, c) = [int(x) for x in input().split()]
M = process(c, r)
for r in M:
	print(' '.join(map(str, r)))


(r, c) = [int(p) for p in input().split()]
if r == 1 and c == 1:
	print(0)
	exit()
elif r == 1:
	print(*list(range(2, c + 2)))
elif c == 1:
	for i in range(2, r + 2):
		print(i)
else:
	matrix = []
	for i in range(1, r + 1):
		row = []
		for j in range(1, c + 1):
			row.append(i * (r + j))
		matrix.append(row)
	for i in matrix:
		print(*i)


import sys
(r, c) = map(int, input().split())
mat = [[0 for i in range(c)] for j in range(r)]
if r == 1 and c == 1:
	sys.exit(print(0))
if r <= c:
	for i in range(r):
		mat[i][0] = (i + 1) * 2
	for i in range(1, r):
		mat[0][i] = 2 * i + 1
	l = 2 * r + 1
	for i in range(r, c):
		mat[0][i] = l
		l += 1
	for i in range(1, r):
		for j in range(1, c):
			mat[i][j] = mat[0][j] * mat[i][0]
	for i in range(r):
		print(*mat[i])
else:
	for i in range(c):
		mat[0][i] = (i + 1) * 2
	for i in range(1, c):
		mat[i][0] = 2 * i + 1
	l = 2 * c + 1
	for i in range(c, r):
		mat[i][0] = l
		l += 1
	for i in range(1, r):
		for j in range(1, c):
			mat[i][j] = mat[0][j] * mat[i][0]
	for i in range(r):
		print(*mat[i])


import sys

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lgcd(x):
	result = x[0]
	for a in x:
		result = gcd(result, a)
	return result

def check(result):
	gcds = []
	for i in range(len(result)):
		row = result[i]
		gcds.append(lgcd(row))
	for j in range(len(result[0])):
		x = []
		for i in range(len(result)):
			x.append(result[i][j])
		gcds.append(lgcd(x))
	print(gcds)
	if len(list(set(gcds))) - len(result) - len(result[0]) != 0:
		print('ERRRRORRR', len(result), len(result[0]))

def solve(r, c):
	if r == 1 and c == 1:
		print(0)
	elif r == 1:
		print(' '.join(map(str, range(2, c + 2))))
	elif c == 1:
		for i in range(r):
			print(i + 2)
	else:
		result = [[0 for _ in range(c)] for _ in range(r)]
		result[0][0] = 2
		used = []
		if c < r:
			for j in range(1, c):
				result[0][j] = (j + 1) * 2
				used.append((j + 1) * 2)
			cur = 3
			for i in range(1, r):
				while cur in used:
					cur += 1
				result[i][0] = cur
				cur += 1
		else:
			for j in range(1, r):
				result[j][0] = (j + 1) * 2
				used.append((j + 1) * 2)
			cur = 3
			for i in range(1, c):
				while cur in used:
					cur += 1
				result[0][i] = cur
				cur += 1
		cur = 5
		(ipos, jpos) = (2, 2)
		for i in range(1, r):
			for j in range(1, c):
				result[i][j] = result[i][0] * result[0][j]
		for i in range(r):
			print(' '.join(map(str, result[i])))
(r, c) = map(int, sys.stdin.readline().strip().split(' '))
solve(r, c)


(m, n) = [int(i) for i in input().split()]
M = [[0] * n for i in range(m)]
if m >= n:
	ln = [i + 1 for i in range(n)]
	st = [i + n + 1 for i in range(m)]
else:
	ln = [i + 1 + m for i in range(n)]
	st = [i + 1 for i in range(m)]
if n == m == 1:
	print(0)
else:
	for i in range(m):
		for j in range(n):
			g = ln[j] * st[i]
			print(g, end=' ')
		print('')


(r, c) = list(map(int, input().split()))
if r == 1 and c == 1:
	print(0)
	raise SystemExit
a = [[1 for j in range(c)] for i in range(r)]
k = 1
if True:
	for i in range(r):
		for j in range(c):
			a[i][j] = a[i][j] * k
		k = k + 1
if c > 1:
	for j in range(c):
		for i in range(r):
			a[i][j] = a[i][j] * k
		k = k + 1
else:
	k = 2
	for i in range(r):
		a[i][0] = k
		k = k + 1
for i in range(r):
	for j in range(c):
		print(a[i][j], end=' ')
	print()


import sys

def gcd(a, b):
	if min(a, b) == 0:
		return max(a, b)
	if a >= b:
		return gcd(a % b, b)
	elif b > a:
		return gcd(a, b % a)
(n, m) = list(map(int, input().split()))
if n == 1 and m == 1:
	print(0)
	exit()
a = []
if n == 1:
	for i in range(m):
		a.append(str(i + 2))
	print(' '.join(a))
	exit()
for i in range(n):
	a.append([0] * m)
for i in range(n):
	a[i][0] = i + 2
num = n + 1
for i in range(len(a)):
	for j in range(1, len(a[i])):
		a[i][j] = a[i][0] * (num + j)
for i in range(len(a)):
	sys.stdout.write(' '.join(list(map(str, a[i]))) + '\n')


(r, c) = map(int, input().split())
if r == c == 1:
	print(0)
	exit()
if c == 1:
	print(*range(2, r + 2))
	exit()
if r == 1:
	print(*range(2, c + 2))
	exit()
ri = list(range(1, r + 1))
cj = list(range(r + 1, r + c + 1))
for i in range(r):
	for j in range(c):
		print(ri[i] * cj[j], end=' ')
	print()


(n, m) = map(int, input().split())
transpose = False
if n > m:
	transpose = True
	(n, m) = (m, n)
if n == 1 and m == 1:
	print(0)
else:
	mat = [[i + 2 for i in range(m)]]
	for i in range(1, n):
		mul = m + 1 + i
		l = []
		for j in range(m):
			l.append(mat[0][j] * mul)
		mat.append(l)
	if transpose:
		for i in range(m):
			for j in range(n):
				print(mat[j][i], end=' ')
			print('')
	else:
		for i in mat:
			print(*i)


dim = list(map(int, input().split()))
row = dim[0]
col = dim[1]
if row == 1 and col == 1:
	print(0)
elif row == 1:
	for c in range(col):
		print(c + 2, end=' ')
	print('')
elif col == 1:
	for r in range(row):
		print(r + 2)
else:
	for r in range(row):
		for c in range(col):
			print((r + 1) * (c + row + 1), end=' ')
		print('')


import sys
(n, m) = map(int, sys.stdin.readline().split())
if n == 1 or m == 1:
	if n == 1 and m == 1:
		sys.stdout.write('0\n')
	elif n == 1:
		for i in range(2, m + 2):
			sys.stdout.write(str(i) + ' ')
		sys.stdout.write('\n')
	else:
		for i in range(2, n + 2):
			sys.stdout.write(str(i) + '\n')
else:
	col = [1]
	row = [i + 2 for i in range(n)]
	for i in range(n + 2, m + n + 1):
		col.append(i)
	for i in range(n):
		for j in range(m):
			sys.stdout.write(str(col[j] * row[i]) + ' ')
		sys.stdout.write('\n')


(a, b) = map(int, input().split())
if a == 1 and b == 1:
	print(0)
elif a > 1 and b == 1:
	for i in range(a):
		print(i + 2)
else:
	l1 = []
	l2 = []
	for i in range(b):
		l1.append(2 + i)
		print(2 + i, end=' ')
	print()
	t = l1[len(l1) - 1] + 1
	for i in range(a - 1):
		for j in range(len(l1)):
			print(t * l1[j], end=' ')
		t += 1
		print()


from collections import deque
import sys
input = sys.stdin.buffer.readline
x = input().split()
(r, c) = map(int, x)
mult = 1
if r == c and r == 1:
	print(0)
elif c == 1:
	for i in range(r):
		print(i + 2)
else:
	for i in range(r):
		ou = []
		for j in range(c):
			ou.append(str(mult * (r + j + 1)))
		print(' '.join(ou))
		mult += 1


(r, c) = map(int, input().split())
if (r, c) == (1, 1):
	print(0)
elif r == 1:
	print(*range(2, c + 2))
elif c == 1:
	print(*range(2, r + 2), sep='\n')
else:
	for i in range(r):
		print(*((i + 1) * (r + 1 + j) for j in range(c)))


import sys
input = sys.stdin.readline
(R, C) = map(int, input().split())
if R == 1 and C == 1:
	print(0)
elif R == 1:
	ans = list(range(2, C + 2))
	print(*ans)
elif C == 1:
	ans = list(range(2, R + 2))
	print(*ans, sep='\n')
else:
	for r in range(2, 2 + R):
		print(r, end=' ')
		for c in range(2 + R, 2 + R + C - 1):
			print(r * c, end=' ')
		print()


def l(g, c):
	(g, c) = (max(g, c), min(g, c))
	h = g
	while h % c != 0:
		h += g
	return h
(x, y) = map(int, input().split())
if x == y == 1:
	exit(print(0))
elif y == 1:
	for i in range(x):
		print(2 + i)
	exit()
elif x == 1:
	print(*list(range(2, y + 2)))
	exit()
mn = min(x, y)
mx = max(x, y)
o = [2 + i for i in range(1, (mn - 1) * 2, 2)]
o = o + [i + 2 for i in range(o[-1], o[-1] + mx - mn)]
e = [i for i in range(2, mn * 2 + 1, 2)]
if x > y:
	print(*e)
	for i in range(x - 1):
		print(*[o[i]] + [l(o[i], e[t]) for t in range(1, y)])
else:
	print(*[2] + o)
	for i in range(x - 1):
		print(*[e[i + 1]] + [l(e[i + 1], o[t]) for t in range(y - 1)])


import sys
import math
import itertools
import collections

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
p = sieve(1000)
(r, c) = mi()
ans = [list(range(r + c + 1)[min(r, c) + 1:])]
if r == 1 and c == 1:
	print(0)
elif r == 1:
	print(wr(ans[0]))
elif c == 1:
	for i in range(r):
		print(ans[0][i])
else:
	for i in range(1, max(r, c), 1):
		ans.append([n * (i + 1) for n in ans[0]])
	if r > c:
		for i in range(r):
			for j in range(c):
				print(ans[j][i], end=' ')
			print()
	else:
		for i in range(r):
			print(wr(ans[i][:c]))


(a, b) = map(int, input().split())
if a == 1 == b:
	print(0)
elif a == 1 != b:
	for i in range(2, b + 2):
		print(i, end=' ')
elif a != 1 == b:
	for i in range(2, a + 2):
		print(i)
else:
	for i in range(1, a + 1):
		for j in range(1, b + 1):
			print(i * (j + a), end=' ')
		print()


(r, c) = map(int, input().split())
f = 0
if r == 1 and c == 1:
	print(0)
	exit()
if c == 1:
	for i in range(2, r + 2):
		print(i)
else:
	pr = [i for i in range(2, c + 2)]
	n = c + 2
	mat = [pr]
	for i in range(2, r + 1):
		mat.append([n * mat[0][0]])
		for j in range(1, c):
			mat[i - 1].append(n * mat[0][j])
		n += 1
	for i in range(r):
		for j in range(c):
			print(mat[i][j], end=' ')
		print()


(r, c) = list(map(int, input().split()))
if r < 2 and c < 2:
	print(0)
elif r * (r + c) >= 10 ** 9:
	print(0)
else:
	if r < c:
		rgcd = [i for i in range(1, r + 1)]
		cgcd = [i for i in range(r + 1, r + c + 1)]
	else:
		rgcd = [i for i in range(c + 1, r + c + 1)]
		cgcd = [i for i in range(1, c + 1)]
	mat = []
	for i in range(r):
		row = []
		for j in range(c):
			row.append(0)
		mat.append(row)
	for i in range(len(rgcd)):
		for j in range(len(cgcd)):
			mat[i][j] = str(rgcd[i] * cgcd[j])
	else:
		for i in mat:
			print(' '.join(i))


import sys

def I():
	return list(map(int, input().split()))

def sieve(n):
	p = 2
	primes = [True] * (n + 1)
	while p * p <= n:
		if primes[p]:
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return primes
(r, c) = I()
a = [[0 for i in range(r)] for j in range(c)]
if r == 1 and c == 1:
	print(0)
	sys.exit(0)
a[0][0] = 2
d = 2
f = 0
if r == 1:
	for i in range(c):
		a[i][0] = i + 2
	f = 1
if c == 1:
	for i in range(r):
		a[0][i] = i + 2
	f = 1
if not f:
	for j in range(c):
		for i in range(r):
			a[j][i] = (i + 1) * (r + j + 1)
for i in range(r):
	for j in range(c):
		print(a[j][i], end=' ')
	print()


(r, c) = map(int, input().split())
su = r + c
res = []
l = [i for i in range(2, c + 2)]
res.append(l)
st = c + 2
if c == 1:
	for i in range(r - 1):
		res.append([i + 3])
else:
	for i in range(r - 1):
		ll = [i * st for i in l]
		res.append(ll)
		st += 1
if r == 1 and c == 1:
	print(0)
else:
	for i in res:
		print(*i)


(a, b) = map(int, input().split())
if a == 1 and b == 1:
	print(0)
else:
	o1 = 0
	o2 = 0
	i1 = []
	i2 = []
	if a < b:
		i1.append(1)
		o1 = 1
	else:
		i2.append(1)
		o2 = 1
	for i in range(2, a + b + 1):
		if o1 < a:
			o1 += 1
			i1.append(i)
		else:
			o2 += 1
			i2.append(i)
	for i in range(a):
		for j in range(b):
			print(i1[i] * i2[j], end=' ')
		print()


(r, c) = map(int, input().split())
if r == c and r == 1:
	print(0)
else:
	ans = list()
	ans.append([x + 2 for x in range(c)])
	for i in range(r - 1):
		g1 = c + 2 + i
		temp = []
		for j in range(c):
			temp.append(g1 * ans[0][j])
		ans.append(temp)
	if c == 1:
		ans = [[el + 2] for el in range(r)]
	for i in range(r):
		for j in range(c):
			print(ans[i][j], end=' ')
		print()


(n, m) = map(int, input().split())
if 1 == n == m:
	print(0)
elif 1 == m:
	for i in range(2, n + 2):
		print(i)
else:
	print(' '.join(map(str, range(2, m + 2))))
	for i in range(n - 1):
		print(' '.join(map(str, range((m + 2 + i) * 2, (m + 2 + i) * (m + 1) + 1, m + 2 + i))))


(n, m) = map(int, input().split())
a = list(range(1, n + 1))
b = list(range(n + 1, n + m + 1))
if n == 1 and m == 1:
	print(0)
	exit()
if n == 1:
	print(*list(range(2, m + 2)))
	exit()
if m == 1:
	print(*list(range(2, n + 2)), sep='\n')
	exit()
res = [[0] * m for i in range(n)]
for i in range(n):
	for j in range(m):
		res[i][j] = a[i] * b[j]
for i in res:
	print(*i)


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
	exit()
b = [i for i in range(1, r + c + 1)]
if r < c:
	gcd_r = b[:r]
	gcd_c = b[r:r + c]
else:
	gcd_c = b[:c]
	gcd_r = b[c:c + r]
a = [[0 for j in range(c)] for i in range(r)]
for i in range(r):
	for j in range(c):
		a[i][j] = gcd_r[i] * gcd_c[j]
for i in range(r):
	print(' '.join(map(str, a[i])))


from sys import stdin

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))

def main():
	(r, c) = lin()
	if r == 1 == c:
		print(0)
	else:
		if c == 1:
			ans = [2 + i for i in range(r)]
			print(*ans, sep='\n')
			return
		ans = [[2 + i for i in range(c)]]
		ch = 2 + c
		for i in range(r - 1):
			ans.append([ch * ans[0][j] for j in range(c)])
			ch += 1
		for r in ans:
			print(*r)
main()


rd = lambda : list(map(int, input().split()))
(r, c) = rd()
if c == 1 and r == 1:
	print(0)
elif c == 1:
	for i in range(1, r + 1):
		print(i + 1)
else:
	for i in range(1, r + 1):
		for j in range(1, c + 1):
			if i == 1:
				print(j + 1, end=' ')
			else:
				print((j + 1) * (c + i), end=' ')
		print()


import math
(n, m) = map(int, input().split())
if n == 1 and m == 1:
	print(0)
elif n == 1:
	for i in range(2, m + 2):
		print(i, end=' ')
elif m == 1:
	for i in range(2, n + 2):
		print(i)
else:
	a = [[0 for i in range(m)] for j in range(n)]
	for i in range(n):
		for j in range(m):
			a[i][j] = (i + 1) * (j + 1 + n)
	for i in a:
		print(' '.join(map(str, i)))


topCube = {20, 19, 18, 17, 16, 15}
(a, b) = list(map(int, input().strip().split()))

def calc():
	if a == 1 and b == 1:
		print(0)
		return
	if b == 1:
		for i in range(2, a + 2):
			print(i)
		return
	if a == 1:
		for i in range(2, b + 1):
			print(i, end=' ')
		print(b + 1)
		return
	r = [0] * a
	c = [0] * b
	for i in range(a):
		r[i] = 2 * i + 1
		if i > b:
			r[i] = r[i - 1] + 1
		if a <= b:
			r[i] = 2 * i + 2
	for j in range(b):
		c[j] = 2 * j + 1
		if j > a:
			c[j] = c[j - 1] + 1
		if a > b:
			c[j] = 2 * j + 2
	c[0] = r[0] = 2
	for i in range(a):
		for j in range(b):
			if i == 0:
				print(c[j], end=' ')
				continue
			if j == 0:
				print(r[i], end=' ')
				continue
			print(c[j] * r[i], end=' ')
		print()
calc()


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif r == 1:
	for i in range(2, c + 2):
		print(i, end=' ')
	print()
elif c == 1:
	for i in range(2, r + 2):
		print(i)
	print()
else:
	(t1, t2) = (r, c)
	s = set()
	(r, c) = (max(r, c), min(r, c))
	mat = list()
	for i in range(c):
		mat.append(list())
	for i in range(c, 0, -1):
		mat[c - i].append(i * 2)
		s.add(i * 2)
	k = 3
	for i in range(r - 1):
		mat[c - 1].append(k)
		s.add(k)
		while k in s:
			k += 1
	for i in range(c - 1):
		for j in range(r - 1):
			mat[i].append(mat[c - 1][j + 1] * mat[i][0])
	if t1 > t2:
		for i in range(r):
			for j in range(c):
				print(mat[j][i], end=' ')
			print()
	else:
		for i in mat:
			print(*i)


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
	exit()
a = [[-1] * c for _ in range(r)]
if r == 1 or c == 1:
	k = 2
	for i in range(r):
		for j in range(c):
			a[i][j] = k
			k += 1
else:
	for i in range(r):
		for j in range(c):
			a[i][j] = (i + 1) * (r + 1 + j)
for ai in a:
	print(*ai)


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import itertools
import bisect
import heapq

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	for i in range(2, n + 1):
		if primes[i]:
			for j in range(i + i, n + 1, i):
				primes[j] = False
	p = []
	for i in range(0, n + 1):
		if primes[i]:
			p.append(i)
	return p

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s
(n, m) = map(int, input().split())
if n == 1 and m == 1:
	print(0)
elif n == 1:
	for i in range(0, m):
		print(i + 2, end=' ')
elif m == 1:
	for i in range(0, n):
		print(i + 2)
else:
	ans = [[] for i in range(0, n)]
	for i in range(0, m):
		ans[0].append(i + 2)
	mul = ans[0][-1]
	for r in range(1, n):
		tbm = mul + r
		for c in range(0, m):
			ans[r].append(ans[0][c] * tbm)
	for i in ans:
		print(*i)


def gcd(a, b):
	while a > 0 and b > 0:
		if a >= b:
			a %= b
		else:
			b %= a
	return a + b

def lcm(a, b):
	return a * b // gcd(a, b)
(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif r >= c:
	a = [[0 for i in range(c)] for j in range(r)]
	bstroka = [i for i in range(1, 1 + c)]
	bstolbi = [i for i in range(1 + c, 1 + c + r)]
	for i in range(r):
		for j in range(c):
			a[i][j] = lcm(bstolbi[i], bstroka[j])
	for i in a:
		print(' '.join(map(str, i)))
else:
	a = [[0 for i in range(c)] for j in range(r)]
	bstolbi = [i for i in range(1, 1 + r)]
	bstroka = [i for i in range(1 + r, 1 + c + r)]
	for i in range(r):
		for j in range(c):
			a[i][j] = lcm(bstolbi[i], bstroka[j])
	for i in a:
		print(' '.join(map(str, i)))


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif r == 1:
	for i in range(c):
		print(i + 2, end=' ')
	print()
elif c == 1:
	for i in range(r):
		print(i + 2)
else:
	for i in range(c + 1, c + r + 1):
		line = ' '.join((str(i * x) for x in range(1, c + 1)))
		print(line)


from math import gcd
import sys
input = sys.stdin.readline
inf = 100000000000000000
mod = 998244353
(n, m) = map(int, input().split())
A = [[0] * m for i in range(n)]
for i in range(m):
	A[0][i] = i + 2
cnt = m + 1
for i in range(1, n):
	cnt += 1
	for j in range(m):
		A[i][j] = A[0][j] // gcd(A[0][j], cnt) * cnt
if n + m == 2:
	print(0)
	sys.exit()
elif m == 1:
	for i in range(n):
		print(i + 2)
	sys.exit()
for i in range(n):
	for j in range(m):
		print(A[i][j], end=' ')
	print()


import functools
import math
import sys

def gcd(l):
	return functools.reduce(math.gcd, l)
(R, C) = map(int, input().split())
if R == C == 1:
	print('0')
	sys.exit(0)
if R < C:
	arr1 = list(range(1, R + 1))
	arr2 = list(range(R + 1, R + C + 1))
else:
	arr2 = list(range(1, C + 1))
	arr1 = list(range(C + 1, R + C + 1))
arr = [[None] * C for _ in range(R)]
for i in range(R):
	for j in range(C):
		arr[i][j] = arr1[i] * arr2[j]
for row in arr:
	print(' '.join(map(str, row)))


def main():
	(r, c) = map(int, input().split())
	a = min(r, c)
	if r == 1 and c == 1:
		print(0)
	elif c == 1:
		for i in range(r):
			print(i + 2)
	else:
		for i in range(r):
			for j in range(r, r + c):
				print((i + 1) * (j + 1), end=' ')
			print()
main()


from math import factorial
from collections import Counter, defaultdict
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	(r, c) = RL()
	res = [[0] * c for _ in range(r)]
	if r == 1 or c == 1:
		if r == 1 and c == 1:
			print(0)
		elif r == 1:
			print(*[i for i in range(2, c + 2)])
		else:
			for i in range(2, r + 2):
				print(i)
	else:
		for i in range(1, r + 1):
			for j in range(1, c + 1):
				res[i - 1][j - 1] = i * (j + r)
		for i in res:
			print(*i)
main()


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
	exit(0)
if r == 1 or c == 1:
	for i in range(2, max(r, c) + 2):
		print(i)
	exit(0)
ans = [[1 for i in range(c)] for j in range(r)]
for i in range(r):
	for j in range(c):
		ans[i][j] = (i + 1) * (r + j + 1)
for row in ans:
	for col in row:
		print(col, end=' ')
	print()


(r, c) = map(int, input().split())
test = set()
ans = list()
for i in range(r):
	ans.append(list())
	for j in range(c):
		ans[-1].append(0)
b = list()
for i in range(1, r + c + 1):
	b.append(i)
maxi = 0
test.add(0)
if r == 1 and c == 1:
	print(0)
elif r == 1:
	ans1 = list()
	for i in range(1, c + 1):
		ans1.append(i + 1)
	print(*ans1)
elif c == 1:
	ans1 = list()
	for i in range(1, r + 1):
		ans1.append(i + 1)
	for i in ans1:
		print(i)
else:
	for i in range(r):
		for j in range(c):
			x = 0
			k = 1
			while x in test:
				x = k * b[i] * b[j + r]
				k += 1
			test.add(x)
			ans[i][j] = x
			if x > maxi:
				maxi = x
	for i in ans:
		print(*i)


def main():
	(R, C) = list(map(int, input().split()))
	if R == C == 1:
		print('0')
	else:
		t = [[0 for _ in range(C)] for _ in range(R)]
		if R == 1:
			for i in range(C):
				t[0][i] = i + 1 + 1
		elif C == 1:
			for i in range(R):
				t[i][0] = i + 1 + 1
		else:
			for r in range(R):
				for c in range(C):
					t[r][c] = (r + 1) * (c + 1 + R)
		for r in range(R):
			print(*t[r])
main()


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
else:
	a = list()
	for i in range(r):
		b = list()
		for j in range(c):
			b.append(0)
		a.append(b)
	a[0][0] = 2
	h = 2
	if r <= c:
		for i in range(1, min(r, c)):
			a[0][i] = 1 + i * 2
			h = max(a[0][i], h)
		for i in range(1, min(r, c)):
			a[i][0] = 2 + i * 2
			h = max(a[i][0], h)
	else:
		for i in range(1, min(r, c)):
			a[0][i] = 2 + i * 2
			h = max(a[0][i], h)
		for i in range(1, min(r, c)):
			a[i][0] = 1 + i * 2
			h = max(a[i][0], h)
	h += 1
	for i in range(min(r, c), c):
		a[0][i] = h
		h += 1
	for i in range(min(r, c), r):
		a[i][0] = h
		h += 1
	for i in range(c):
		print(a[0][i], end=' ')
	print()
	for i in range(1, r):
		for j in range(0, c):
			if j == 0:
				print(a[i][0], end=' ')
			elif j > 0:
				qw = a[i][0] * a[0][j]
				print(qw, end=' ')
		print()


(r, c) = [int(i) for i in input().split(' ')]
if r == c == 1:
	print(0)
elif c != 1:
	res = [[0] * c for _ in range(r)]
	for j in range(r):
		print(' '.join([str((j + 1) * (r + k + 1)) for k in range(c)]))
elif c == 1:
	for j in range(r):
		print(j + 2)


(r, c) = [int(i) for i in input().split()]
if 1 == r == c:
	print(0)
elif c == 1:
	for i in range(c + 1, r + c + 1):
		print(*[i * j for j in range(1, c + 1)])
else:
	for i in range(1, r + 1):
		print(*[i * j for j in range(r + 1, r + c + 1)])


from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt, gcd
import unittest

def read_int():
	return int(input().strip())

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
(r, c) = read_int_array()
if r == c == 1:
	print(0)
	exit()
if r == 1:
	print(' '.join((str(e) for e in range(2, c + 2))))
	exit()
if c == 1:
	print('\n'.join((str(e) for e in range(2, r + 2))))
	exit()
print('\n'.join((' '.join((str(i * j) for j in range(r + 1, r + c + 1))) for i in range(1, r + 1))))


from __future__ import division, print_function

def main():
	import sys
	data = iter(map(int, sys.stdin.buffer.read().decode('ascii').split()))
	(r, c) = (next(data), next(data))
	if r == 1 and c == 1:
		print(0)
		return 0
	transpose = False
	if r > c:
		(r, c) = (c, r)
		transpose = True
	rr = list(range(1, r + 1))
	cc = list(range(r + 1, r + c + 1))
	if transpose:
		(r, c) = (c, r)
		(rr, cc) = (cc, rr)
	res = [None] * r
	for i in range(r):
		res[i] = ' '.join((str(rr[i] * val) for val in cc))
	sys.stdout.buffer.write('\n'.join((str(x) for x in res)).encode('ascii'))
	return 0
main()


import sys
[r, c] = [int(i) for i in sys.stdin.readline().split()]
if r == 1 and c == 1:
	print(0)
elif r == 1:
	d = 2
	for k in range(c):
		print(d, end=' ')
		d += 1
	print()
else:
	arr = []
	for i in range(r):
		tmp = []
		for j in range(c):
			tmp.append(0)
		arr.append(tmp)
	rows = []
	cols = []
	num = 1
	for e in range(c):
		cols.append(num)
		num += 1
	for f in range(r):
		rows.append(num)
		num += 1
	for h in range(c):
		for g in range(r):
			arr[g][h] = cols[h] * rows[g]
	for a in range(r):
		for b in range(c):
			print(arr[a][b], end=' ')
		print()


(n, m) = map(int, input().split())
if n == 1 and m == 1:
	print(0)
else:
	ans = []
	if m == 1:
		ans = [[q] for q in range(2, n + 2)]
	else:
		ans = [[q for q in range(2, m + 2)]]
		for q in range(2, n + 1):
			ans.append([])
			for q1 in range(m):
				ans[-1].append(ans[0][q1] * (m + q))
	for q in ans:
		print(*q)


from random import randint

def NOK(a, b):
	m = a * b
	if a < b:
		(a, b) = (b, a)
	while a % b:
		a %= b
		if a < b:
			(a, b) = (b, a)
	return m // b
A = []
(r, c) = map(int, input().split())
if (r, c) == (1, 1):
	print(0)
elif r == 1:
	for i in range(2, c + 2):
		print(i, end=' ')
elif c == 1:
	for i in range(2, r + 2):
		print(i)
else:
	k = 0
	i = 1
	while k < r + c:
		A.append(i)
		k += 1
		i += 1
	(B, C) = (A[:r], A[r:])
	for i in range(r):
		for j in range(c):
			print(NOK(B[i], C[j]), end=' ')
		print('')


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
elif r == 1:
	print(*[i + 2 for i in range(c)])
elif c == 1:
	for i in range(r):
		print(i + 2)
else:
	start_row = [i + r + 1 for i in range(c)]
	print(*start_row)
	for row in range(1, r):
		print(*[i * (row + 1) for i in start_row])


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

def getlist():
	return list(map(int, input().split()))

def main():
	(R, C) = getlist()
	if R == 1 and C == 1:
		print(0)
		return
	if C == 1:
		for i in range(R):
			print(2 + i)
		return
	L = [[0] * C for i in range(R)]
	s = R + 1
	for i in range(C):
		L[0][i] = s + i
	for j in range(C):
		s = L[0][j]
		for i in range(R):
			L[i][j] = s * (i + 1)
	for i in range(R):
		print(' '.join(list(map(str, L[i]))))
main()


(r, c) = list(map(int, input().strip().split()))
if r == c == 1:
	print(0)
elif r == 1 or c == 1:
	x = 2
	for i in range(r):
		for j in range(c):
			print(x, end=' ')
			x += 1
		print()
else:
	for i in range(1, 1 + r):
		for j in range(1, 1 + c):
			print(i * (r + j), end=' ')
		print()


(n, m) = map(int, input().split())
if min(n, m) == 1:
	if n == 1:
		a = [[i + 2 for i in range(m)] for j in range(n)]
	else:
		a = [[j + 2 for i in range(m)] for j in range(n)]
else:
	a = [[j + 1 for i in range(m)] for j in range(n)]
	for i in range(n):
		for j in range(m):
			a[i][j] *= n + j + 1
if n + m == 2:
	print('0')
else:
	for i in a:
		for j in i:
			print(j, end=' ')
		print()


import sys
input = sys.stdin.readline
(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
	exit()
if c == 1:
	C = [1]
	R = list(range(2, r + 2))
else:
	R = list(range(1, r + 1))
	C = list(range(r + 1, c + r + 1))
L = [[0] * c for _ in range(r)]
for i in range(r):
	for j in range(c):
		L[i][j] = R[i] * C[j]
for s in L:
	print(' '.join(map(str, s)))


import sys
from collections import defaultdict, deque
import math

def inar():
	return [int(ek) for ek in input().split()]
(r, c) = inar()
matrix = [[0 for j in range(c)] for i in range(r)]
if r == 1 and c == 1:
	print(0)
else:
	if r == 1 or c == 1:
		count = 2
		for i in range(r):
			for j in range(c):
				matrix[i][j] = count
				count += 1
	else:
		for i in range(r):
			for j in range(c):
				matrix[i][j] = (i + 1) * (j + 1 + r)
	for i in range(r):
		print(*matrix[i])


(h, m) = list(map(int, input().split()))
a = [[0] * m for i in range(h)]
if h == min(h, m):
	for i in range(h):
		a[i][0] = (i + 1) * 2
	for i in range(1, m):
		if 2 * i <= a[h - 1][0]:
			a[0][i] = 2 * i + 1
		else:
			a[0][i] = a[0][i - 1] + 1
else:
	for i in range(m):
		a[0][i] = (i + 1) * 2
	for i in range(1, h):
		if 2 * i <= a[0][m - 1]:
			a[i][0] = 2 * i + 1
		else:
			a[i][0] = a[i - 1][0] + 1
for i in range(1, h):
	for j in range(1, m):
		a[i][j] = a[i][0] * a[0][j]
if h == 1 and m == 1:
	print(0)
else:
	for i in range(h):
		print(*a[i])


(r, c) = [int(a) for a in input().split()]
rr = list(range(1, r + 1))
cc = list(range(r + 1, r + c + 1))
if r == 1 and c == 1:
	print(0)
	exit()
elif c == 1:
	rr.remove(1)
	rr.insert(0, cc[0])
	cc[0] = 1
for R in rr:
	for C in cc:
		print(R * C, end=' ')
	print('')


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def si():
	return input()

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def power_set(L):
	cardinality = len(L)
	n = 2 ** cardinality
	powerset = []
	for i in range(n):
		a = bin(i)[2:]
		subset = []
		for j in range(len(a)):
			if a[-j - 1] == '1':
				subset.append(L[j])
		powerset.append(subset)
	powerset_orderred = []
	for k in range(cardinality + 1):
		for w in powerset:
			if len(w) == k:
				powerset_orderred.append(w)
	return powerset_orderred

def fastPlrintNextLines(a):
	print('\n'.join(map(str, a)))

def sortByFirstAndSecond(A):
	A = sorted(A, key=lambda x: x[0])
	A = sorted(A, key=lambda x: x[1])
	return list(A)
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = 1
for _ in range(t):
	(r, c) = li()
	if r == 1 and c == 1:
		print(0)
		continue
	if c == 1:
		for i in range(2, r + 2):
			print(i)
		continue
	l = [[0 for i in range(c)] for j in range(r)]
	for i in range(r):
		for j in range(c):
			l[i][j] = (i + 1) * (j + r + 1)
	for i in l:
		print(*i)


(r, c) = map(int, input().strip().split())
if r == 1 and c == 1:
	print('0')
elif c == 1:
	for i in range(2, r + 2):
		print(i)
else:
	x = 1
	while x <= r:
		t = 1
		while t <= c:
			print(x * (r + t), end=' ')
			t += 1
		print()
		x += 1


(m, n) = map(int, input().split())
if m == 1 and n == 1:
	print(0)
	exit(0)
if n == 1:
	for i in range(m):
		print(i + 2)
	exit(0)
l = [[j + 1 for i in range(n)] for j in range(m)]
for i in range(n):
	for list in l:
		list[i] *= m + 1 + i
for i in l:
	print(*i)


l = list(map(int, input().split()))
(r, c) = (l[0], l[1])
if r == 1 and c == 1:
	print(0)
elif r <= c:
	rs = [i for i in range(1, r + 1)]
	cs = [i for i in range(r + 1, r + c + 1)]
	k = [[0 for i in range(c)] for j in range(r)]
	for i in range(r):
		for j in range(c):
			k[i][j] = rs[i] * cs[j]
	for i in range(r):
		for j in range(c):
			print(k[i][j], end=' ')
		print()
else:
	cs = [i for i in range(1, c + 1)]
	rs = [i for i in range(c + 1, r + c + 1)]
	k = [[0 for i in range(c)] for j in range(r)]
	for i in range(r):
		for j in range(c):
			k[i][j] = rs[i] * cs[j]
	for i in range(r):
		for j in range(c):
			print(k[i][j], end=' ')
		print()


(r, c) = list(map(int, input().split()))
if r == 1 and c == 1:
	print(0)
elif r == 1 and c != 1:
	cnt = 2
	temp = [cnt + i for i in range(c)]
	print(*temp)
elif r != 1 and c == 1:
	cnt = 2
	for i in range(r):
		print(cnt + i)
else:
	mat = []
	temp = [r + i + 1 for i in range(c)]
	mat.append(temp)
	cnt = 2
	for i in range(r - 1):
		t = []
		for j in range(len(temp)):
			t.append(temp[j] * cnt)
		cnt += 1
		mat.append(t)
	for i in mat:
		print(*i)


def inp():
	return map(int, stdin.readline().split())

def get_col(arr, i):
	return [row[i] for row in arr]
from sys import *
(r, c) = inp()
ans = []
if r == c == 1:
	exit(print(0))
if r > 1 and c == 1:
	for i in range(2, r + 2):
		print(i, end=' ')
	exit()
lis = [i for i in range(2, 2 + c)]
ans.append(lis)
for i in range(1, r):
	lis2 = []
	for j in range(c):
		lis2.append(lis[j] * (i + c + 1))
	ans.append(lis2)
for i in range(r):
	print(*ans[i])


(r, c) = map(int, input().split())
a = [[0 for i in range(c)] for i in range(r)]
if r == c and r == 1:
	print(0)
	exit()
if c == 1:
	for i in range(2, r + 2):
		print(i)
	exit()
for i in range(r):
	for j in range(c):
		a[i][j] = (i + 1) * (j + 1 + r)
for i in a:
	print(*i)


(origr, origc) = map(int, input().split())
(r, c) = sorted([origr, origc])
if r == c == 1:
	print(0)
else:
	rows = range(1, r + 1)
	cols = range(r + 1, c + r + 1)
	if origr <= origc:
		for i in rows:
			print(*[i * j for j in cols])
	else:
		for j in cols:
			print(*[i * j for i in rows])


import os
import sys
import bisect
from math import gcd, ceil
from heapq import heapify, heappop, heappush
from io import BytesIO, IOBase

def main():
	(r, c) = map(int, input().split())
	n = r + c
	nums = [i for i in range(c + 1, r + c + 1)][::-1]
	if r <= 1 and c <= 1:
		print(0)
		return
	elif r == 1:
		for i in range(1, r + c):
			print(i + 1, end=' ')
		print()
	else:
		a = [[0] * c for i in range(r)]
		for i in range(r):
			for j in range(c):
				if j == 0:
					a[i][j] = nums[i]
				else:
					a[i][j] = (j + 1) * a[i][0]
				print(a[i][j], end=' ')
			print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = lambda s: self.buffer.write(s.encode()) if self.writable else None

	def read(self):
		if self.buffer.tell():
			return self.buffer.read().decode('ascii')
		return os.read(self._fd, os.fstat(self._fd).st_size).decode('ascii')

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline().decode('ascii')

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

def print(*args, sep=' ', end='\n', file=sys.stdout, flush=False):
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(end)
	if flush:
		file.flush()
(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.setrecursionlimit(10000)
main()


import sys
import math
(a, b) = list(map(int, input().split()))
k = 1
t = []
if a == 1 and b == 1:
	print(0)
	sys.exit(0)
if a != 1 and b == 1:
	for i in range(a):
		print(i + 2)
	sys.exit(0)
nod = 0
for i in range(1, a + 1):
	for g in range(1, b + 1):
		print(i * (g + a), end=' ')
	nod += 1
	print()


(r, c) = list(map(int, input().split()))
arr = [[0 for i in range(c)] for j in range(r)]
if r == 1 and c == 1:
	print(0)
elif r == 1 or c == 1:
	if r == 1:
		value = 2
		for i in range(c):
			arr[0][i] = value
			value += 1
	else:
		value = 2
		for i in range(r):
			arr[i][0] = value
			value += 1
	for i in range(r):
		for j in range(c):
			if j == c - 1:
				print(arr[i][j])
			else:
				print(arr[i][j], end=' ')
else:
	value = 2
	for i in range(r):
		arr[i][0] = value
		value += 1
	for i in range(1, c):
		for j in range(r):
			arr[j][i] = arr[j][0] * value
		value += 1
	for i in range(r):
		for j in range(c):
			if j == c - 1:
				print(arr[i][j])
				break
			print(arr[i][j], end=' ')


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
(r, c) = rints()
if r == c == 1:
	print(0)
	exit()
if c == 1:
	for y in range(r):
		print(y + 2)
	exit()
for y in range(r):
	print(*((y + 1) * (x + r + 1) for x in range(c)))


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor, log
from bisect import bisect_right, bisect_left, bisect
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def isPowerOfTwo(x):
	return x and (not x & x - 1)
MOD = 1000000007
PMOD = 998244353
N = 10 ** 6
LOGN = 30
alp = 'abcdefghijklmnopqrstuvwxyz'
T = 1
for _ in range(T):
	(r, c) = list(map(int, stdin.readline().rstrip().split()))
	if r == 1 and c == 1:
		print(0)
	elif c == 1:
		for i in range(2, r + 2):
			print(i)
	else:
		a = [[0 for j in range(c)] for i in range(r)]
		for i in range(r):
			for j in range(c):
				a[i][j] = (i + 1) * (r + j + 1)
		for i in a:
			print(*i)


import sys
from math import gcd
input = sys.stdin.readline

def printnl(val):
	sys.stdout.write(str(val) + '\n')

def solve(r, c):
	if r == c == 1:
		print('0')
	elif r == 1 and c != 1:
		n = max(r, c)
		print(*[i for i in range(2, n + 2)])
	elif r != 1 and c == 1:
		n = max(r, c)
		print(*[i for i in range(2, n + 2)], sep='\n')
	else:
		shift = 1
		ans = []
		for i in range(r):
			ans.append([])
			for j in range(c):
				ans[-1].append((j + 2) * shift)
			if i == 0:
				shift += c + 1
			else:
				shift += 1
		for i in range(r):
			print(*ans[i])

def correctness(ans):
	gcds = []
	for i in range(len(ans)):
		g = 0
		for j in range(len(ans[i])):
			g = gcd(ans[i][j], g)
		gcds += [g]
	for i in range(len(ans[0])):
		g = 0
		for j in range(len(ans)):
			g = gcd(ans[i][j], g)
		gcds += [g]
	print(*gcds)
(r, c) = map(int, input().split())
solve(r, c)


from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))

def solve():
	(r, c) = rl()
	if r == c == 1:
		print(0)
	elif r == 1:
		print(*list(range(2, c + 2)))
	elif c == 1:
		for i in range(2, r + 2):
			print(i)
	else:
		for i in range(r):
			m = c + i + 1
			print(*[m * i for i in range(1, c + 1)])
mode = 's'
if mode == 'T':
	t = ri()
	for i in range(t):
		solve()
else:
	solve()


from collections import Counter
for _ in range(1):
	(n, m) = map(int, input().split())
	grid = [[0] * m for i in range(n)]
	for i in range(n):
		for j in range(m):
			grid[i][j] = (i + 1) * (j + 1 + n)
	if n == 1:
		for i in range(m):
			grid[0][i] = i + 2
	if m == 1:
		for i in range(n):
			grid[i][0] = i + 2
	if n == m == 1:
		print(0)
	else:
		for li in grid:
			print(*li)


def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))
(r, c) = [int(x) for x in input().split()]
if r == c == 1:
	print(0)
else:
	ans = [[-1 for _ in range(c)] for __ in range(r)]
	if r == 1:
		for i in range(1, c + 1):
			ans[0][i - 1] = i + 1
	elif c == 1:
		for i in range(1, r + 1):
			ans[i - 1][0] = i + 1
	else:
		for i in range(r):
			for j in range(c):
				ans[i][j] = (i + 1) * (j + r + 1)
	multiLineArrayOfArraysPrint(ans)


(r, c) = map(int, input().split())
if r == 1 and c == 1:
	print(0)
	exit(0)
if r < c:
	rr = [i for i in range(1, r + 1)]
	cc = [i for i in range(r + 1, r + c + 1)]
else:
	cc = [i for i in range(1, c + 1)]
	rr = [i for i in range(c + 1, r + c + 1)]
for i in range(r):
	for j in range(c):
		print(rr[i] * cc[j], end=' ')
	print('')