There is a $n \times m$ grid. You are standing at cell $(1, 1)$ and your goal is to finish at cell $(n, m)$.

You can move to the neighboring cells to the right or down. In other words, suppose you are standing at cell $(x, y)$. You can:

move right to the cell $(x, y + 1)$ — it costs $x$ burles;

move down to the cell $(x + 1, y)$ — it costs $y$ burles.

Can you reach cell $(n, m)$ spending exactly $k$ burles?


-----Input-----

The first line contains the single integer $t$ ($1 \le t \le 100$) — the number of test cases.

The first and only line of each test case contains three integers $n$, $m$, and $k$ ($1 \le n, m \le 100$; $0 \le k \le 10^4$) — the sizes of grid and the exact amount of money you need to spend.


-----Output-----

For each test case, if you can reach cell $(n, m)$ spending exactly $k$ burles, print YES. Otherwise, print NO.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).


-----Examples-----

Input
6
1 1 0
2 2 2
2 2 3
2 2 4
1 4 3
100 100 10000
Output
YES
NO
YES
NO
YES
NO


-----Note-----

In the first test case, you are already in the final cell, so you spend $0$ burles.

In the second, third and fourth test cases, there are two paths from $(1, 1)$ to $(2, 2)$: $(1, 1)$ $\rightarrow$ $(1, 2)$ $\rightarrow$ $(2, 2)$ or $(1, 1)$ $\rightarrow$ $(2, 1)$ $\rightarrow$ $(2, 2)$. Both costs $1 + 2 = 3$ burles, so it's the only amount of money you can spend.

In the fifth test case, there is the only way from $(1, 1)$ to $(1, 4)$ and it costs $1 + 1 + 1 = 3$ burles.

Difficulty: EASY
Tags: Dynamic programming

Mathematics
Skill types: Dynamic programming

Starter code:

Solutions:
t = int(input())
while t > 0:
	x = input()
	x = x.split(' ')
	n = int(x[0])
	m = int(x[1])
	k = int(x[2])
	sum = n - 1 + n * (m - 1)
	if sum == k:
		print('YES')
	else:
		print('NO')
	t -= 1


from sys import stdin, stdout
from collections import defaultdict, Counter, deque
for _ in range(int(stdin.readline())):
	(r, b, d) = map(int, stdin.readline().split())
	a = (min(r, b) - 1) * max(r, b) + (max(r, b) - 1)
	if a == d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	least = min(n, m)
	great = max(n, m)
	so_far = great - 1
	so_far += (least - 1) * great
	if so_far == k:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	sk = 0
	(x, y, z) = input().split()
	x = int(x)
	y = int(y)
	z = int(z)
	sk += y - 1
	sk = sk + y * (x - 1)
	if sk == z:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	(n, m, k) = map(int, input().split())
	score = n - 1 + n * (m - 1)
	if score == k:
		print('YES')
	else:
		print('NO')


import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
	(n, m, k) = map(int, stdin.readline().split())
	ans = n - 1 + n * (m - 1)
	if ans == k:
		ANS.append('YES')
	else:
		ANS.append('NO')
print('\n'.join(ANS))


t = int(input())
for i in range(t):
	(a, b, c) = [int(x) for x in input().split()]
	if a * b == c + 1:
		print('YES')
	else:
		print('NO')


import sys
from math import gcd, ceil, sqrt
INF = float('inf')
MOD = 998244353
mod = 10 ** 9 + 7
from collections import Counter, defaultdict as df
from functools import reduce

def counter(l):
	return dict(Counter(l))

def printm(l):
	for i in range(len(l[0])):
		print(*l[i])

def P(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, ceil(sqrt(n)) + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def so(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def rev(l):
	return list(reversed(l))

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

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

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

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

def inputm(n, m):
	return [li() for i in range(m)]
for i in range(ini()):
	(a, b, c) = inp()
	d = b - 1
	d += (a - 1) * b
	if d == c:
		print('YES')
	else:
		print('NO')


t_case = int(input())
for i in range(t_case):
	lst = input().split()
	(n, m, k) = (int(lst[0]), int(lst[1]), int(lst[2]))
	if n - 1 + n * (m - 1) == k:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m, k) = input().split()
	n = int(n)
	m = int(m)
	k = int(k)
	if k == m * n - 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print('YES' if (max(a, b) - 1) * 1 + (min(a, b) - 1) * max(a, b) == c else 'NO')


n = int(input())
for i in range(n):
	(x, y, d) = list(map(int, input().split()))
	cost = x * y - 1
	if cost == d:
		print('YES')
	else:
		print('NO')


for test_case in range(int(input())):
	(n, m, k) = map(int, input().split())
	(sum1, sum2) = (1 * (n - 1), n * (m - 1))
	if sum1 + sum2 == k:
		print('YES')
	else:
		print('NO')


for g in [*open(0)][1:]:
	(m, n, k) = map(int, g.split())
	print('YNEOS'[k != m * n - 1::2])


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	n2 = n - 1
	m2 = (m - 1) * n
	p = m2 + n2
	if k == p:
		print('YES')
	else:
		print('NO')


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)
	c = dict(Counter(l))
	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 sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

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 si():
	return input()

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()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	(n, m, k) = li()
	ans = 0
	ans2 = 0
	ans = n - 1 + n * (m - 1)
	ans2 = m - 1 + m * (n - 1)
	if ans == k or ans2 == k:
		print('YES')
	else:
		print('NO')
t = 1
t = int(input())
for _ in range(t):
	solve()


import bisect
import math
for _ in range(int(input())):
	f = 0
	(r, c, k) = map(int, input().split())
	mi = min(c - 1 + (r - 1) * c, r - 1 + (c - 1) * r)
	ma = min(c - 1 + (r - 1) * c, r - 1 + (c - 1) * r)
	if k <= ma and k >= mi:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b, m) = map(int, input().split())
	d = b - 1
	e = a - 1
	p = d + e * b
	if m == p:
		print('YES')
	else:
		print('NO')


tcs = int(input())
for tc in range(tcs):
	(n, m, k) = list(map(int, input().split()))
	r = n - 1
	r += (m - 1) * n
	if r == k:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	if k == n * m - 1:
		print('YES')
	else:
		print('NO')


t = int(input(''))
for _ in range(t):
	(x, y, k) = [int(z) for z in input('').split(' ')]
	o = x - 1 + (y - 1) * x
	if o == k:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	[n, m, k] = map(int, input().split())
	print(['NO', 'YES'][n * m - 1 == k])


L = lambda : list(map(int, input().split()))
tc = int(input())
for _ in range(tc):
	(n, m, k) = L()
	cost = 1 * (m - 1) + m * (n - 1)
	print('YES' if cost == k else 'NO')


for i in range(int(input())):
	(n, m, k) = [int(g) for g in input().split()]
	count = 1 * (n - 1) + n * (m - 1)
	if count == k:
		print('Yes')
	else:
		print('No')


ans = set()

def solve(ans, i, j, n, m, c):
	if i == n and j == m:
		ans.add(c)
	if i < n:
		solve(ans, i + 1, j, n, m, c + j)
	if j < m:
		solve(ans, i, j + 1, n, m, c + i)
for a0 in range(int(input())):
	(n, m, k) = [int(x) for x in input().split()]
	if m < n:
		(m, n) = (n, m)
	mi = min(n - 1 + n * (m - 1), m - 1 + m * (n - 1))
	if k == mi:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	res = n * m - 1
	if res == k:
		print('YES')
	else:
		print('NO')


tests = int(input())
for t in range(tests):
	nums = input()
	vars = [int(l) for l in nums.split()]
	xpos = vars[0]
	ypos = vars[1]
	burles = vars[2]
	xcost = 1
	ycost = 1
	cost = 0
	for x in range(xpos - 1):
		xcost += 1
		cost += ycost
	for y in range(ypos - 1):
		cost += xcost
	if cost == burles:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	inp = input().split()
	n = int(inp[0])
	m = int(inp[1])
	k = int(inp[2])
	if n - 1 + n * (m - 1) == k:
		print('YES')
	else:
		print('NO')


t = int(input().strip())
my_list = []
x = 1
y = 1
for _ in range(t):
	grid = list(map(int, input().split()))
	my_list.append(grid)
for (m, n, k) in my_list:
	cost_y = n - 1
	cost_x = n * (m - 1)
	total_cost = cost_x + cost_y
	if total_cost == k:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b, d) = [int(x) for x in input().split()]
	res = a * b - 1
	if res == d:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m, k) = list(map(int, input().rstrip().split()))
	a = [[0 for i in range(m)] for j in range(n)]
	for i in range(n):
		for j in range(m):
			if j == 0:
				a[i][j] = i
			else:
				a[i][j] = a[i][j - 1] + i + 1
	if a[n - 1][m - 1] == k:
		print('YES')
	else:
		print('NO')


t = int(input())

def solve(n, m, k):
	if n * m - 1 == k:
		return 'YES'
	return 'NO'
while t > 0:
	t -= 1
	(n, m, k) = map(int, input().split())
	print(solve(n, m, k))


a = int(input())
for i in range(0, a):
	(r, b, d) = map(int, input().split())
	if r * b - 1 == d:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	lst = input().split()
	(n, m, k) = (int(lst[0]), int(lst[1]), int(lst[2]))
	a = 1 * (m - 1) + m * (n - 1)
	b = 1 * (n - 1) + n * (m - 1)
	if min(a, b) <= k <= max(a, b):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m, k) = list(map(int, input().split()))
	if n == 1 and m == 1 and (k == 0):
		print('YES')
	elif n * m - 1 == k:
		print('YES')
	else:
		print('NO')


from collections import Counter as cc
from copy import deepcopy as dc
import random
import math
MAX_SIZE = 1e+18
try:
	t = int(input())
	while t:
		(n, m, k) = map(int, input().split())
		p = min(m, n) - 1 + (max(m, n) - 1) * min(m, n)
		q = max(m, n) - 1 + (min(m, n) - 1) * max(m, n)
		if p == k or q == k:
			print('YES')
		else:
			print('NO')
except EOFError as e:
	pass


for i in range(int(input())):
	(x, y, d) = [int(x) for x in input().split()]
	if d == x - 1 + x * (y - 1):
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	(x, y, k) = map(int, input().split())
	if x >= y:
		(x, y) = (x, y)
	else:
		(x, y) = (y, x)
	if x - 1 + x * (y - 1) == k:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	if n == m and n == 1:
		if k == 0:
			print('YES')
		else:
			print('NO')
	else:
		c = m - 1 + m * (n - 1)
		if c == k:
			print('YES')
		else:
			print('NO')


from functools import lru_cache

@lru_cache(None)
def get(i, j, n, m, s):
	if s < 0:
		return False
	if i == n and j == m:
		if s == 0:
			return True
		return False
	res = False
	if j + 1 <= m:
		res = res or get(i, j + 1, n, m, s - i)
	if i + 1 <= n:
		res = res or get(i + 1, j, n, m, s - j)
	return res
T = int(input())
for t in range(1, T + 1):
	(n, m, k) = list(map(int, input().split(' ')))
	if get(1, 1, n, m, k):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c) = map(int, input().strip().split())
	total_count = 0
	total_count += b - 1
	answer = (a - 1) * b
	total_count += answer
	if total_count != c:
		print('NO')
	else:
		print('YES')


import sys
import functools
input = sys.stdin.buffer.readline

@functools.lru_cache(None)
def DFS(i, j, k):
	if i == 0 and j == 0:
		return k == 0
	if k < 0:
		return False
	if i == 0:
		return DFS(0, j - 1, k - 1)
	if j == 0:
		return DFS(i - 1, 0, k - 1)
	return DFS(i - 1, j, k - j - 1) or DFS(i, j - 1, k - i - 1)
for _ in range(int(input())):
	(m, n, k) = list(map(int, input().split()))
	m -= 1
	n -= 1
	if DFS(m, n, k):
		print('YES')
	else:
		print('NO')


t = int(input())
for T in range(t):
	(n, m, k) = [int(x) for x in input().split()]
	value = n * m - 1
	if value == k:
		print('YES')
	else:
		print('NO')


test = int(input())
ans = []
while test > 1000 and test < 1:
	test = int(input())
while test > 0:
	ls = list(map(int, input().split()))
	a = ls[0]
	b = ls[1]
	d = ls[2]
	c = b - 1
	cost = (a - 1) * b + c
	if cost == d:
		ans.append('yes')
	else:
		ans.append('no')
	test -= 1
for i in ans:
	print(i)


t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split(' '))
	a = n - 1
	b = m - 1
	s = a + b * n
	if s == k:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, m, k) = map(int, input().strip().split())
	if n * m - 1 == k:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
while t > 0:
	(n, m, k) = map(int, input().split())
	if k == n * m - 1:
		print('Yes')
	else:
		print('No')
	t -= 1


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

def li():
	return [int(i) for i in input().split()]
for t in range(ii()):
	(n, m, k) = li()
	if m - 1 + m * (n - 1) == k:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(x, y, p) = list(map(int, input().split(' ')))
	temp1 = y - 1
	temp2 = y * (x - 1)
	if temp1 + temp2 == p:
		print('YES')
	else:
		print('NO')


from sys import *
import math
input = stdin.readline
I = int
R = range
listInput = lambda : list(map(int, input().strip().split()))
lineInput = lambda : map(int, input().strip().split())
sJoin = lambda a, sep: '{}'.format(sep).join(a)
arrJoin = lambda a, sep: '{}'.format(sep).join(map(str, a))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def main():
	for _ in R(I(input())):
		(n, m, k) = lineInput()
		n -= 1
		m -= 1
		high = m + n * (m + 1)
		print('YES' if k == high else 'NO')
main()


cases = int(input())
for x in range(cases):
	z = 0
	y = 0
	c = input().split(' ')
	(n, m, k) = [int(x) for x in c]
	diff = (n - 1, m - 1)
	z = diff[0] + 1
	print('YES' if n - 1 + z * (m - 1) == k else 'NO')


from io import BytesIO, IOBase
import sys
import math
import os
from collections import defaultdict
from math import ceil
from bisect import bisect_left, bisect_left
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))

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

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

def mfloat():
	return map(float, input().split())

def solve():
	(n, m, k) = mint()
	print('YES' if m * n - 1 == k else 'NO')

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


MAX = 1 << 20
while True:
	try:
		t = eval(input())
		for i in range(t):
			(n, m, k) = map(int, input().split())
			if n * m - 1 == k:
				print('YES')
			else:
				print('NO')
	except:
		break


for _ in range(int(input())):
	(n, m, cost) = map(int, input().split())
	if cost == n * m - 1:
		print('YES')
	else:
		print('NO')


t = int(input(''))
a = []
for i in range(t):
	a.append(input('').split(' '))
for i in a:
	if int(i[2]) == int(i[0]) * int(i[1]) - 1:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	(n, m, k) = map(int, input().split())
	b = min(m - 1 + m * (n - 1), n - 1 + n * (m - 1))
	c = max(m - 1 + m * (n - 1), n - 1 + n * (m - 1))
	if b <= k <= c:
		print('YES')
	else:
		print('NO')


n = int(input())
x = []
for i in range(n):
	x.append(list(map(int, input().split())))
a = 0
b = 0
for i in x:
	a = i[1] - 1
	b = (i[0] - 1) * i[1]
	if a + b == i[2]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(x, y, k) = map(int, input().split())
	if x == 1 and y == 1 and (k == 0):
		print('YES')
	else:
		ans = 0
		ans = x - 1
		ans = ans + (y - 1) * x
		if ans == k:
			print('YES')
		else:
			print('NO')


import math
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	if n * m - 1 == k:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	if k == n * m - 1:
		print('yes')
	else:
		print('no')


cnt = 0
for i in range(int(input())):
	(n, m, burles) = map(int, input().split())
	k = n - 1
	a = (m - 1) * n
	cnt = k + a
	if cnt == burles:
		print('YES')
	else:
		print('NO')


def solve():
	(n, m, k) = map(int, input().split(' '))
	if k == n * m - 1:
		return 'YES'
	return 'NO'
cases = int(input())
for case in range(cases):
	print(solve())


t = int(input())
while t:
	t = t - 1
	(n, m, k) = map(int, input().split(' '))
	(i, j) = (1, 1)
	b = True
	c = 0
	while i != n or j != m:
		if b:
			if j != m:
				j = j + 1
				c += i
			b = False
		if not b:
			if i != n:
				i = i + 1
				c += j
			b = True
	if c == k:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m, k) = list(map(int, input().strip().split()))
	res = m - 1 + m * (n - 1)
	if res == k:
		print('YES')
	else:
		print('NO')


for s in [*open(0)][1:]:
	(n, m, k) = list(map(int, s.split(' ')))
	print('YES' if sum([1 for i in range(1, m)]) + sum([m for _ in range(1, n)]) == k else 'NO')


for t in range(int(input())):
	(n, m, d) = map(int, input().split())
	if n == 1 and m == 1 and (d == 0):
		print('YES')
	elif d == 0:
		print('NO')
	elif n == m:
		if n * n - 1 == d:
			print('YES')
		else:
			print('NO')
	elif m == 1:
		if n - 1 == d:
			print('YES')
		else:
			print('NO')
	elif n == 1:
		if m - 1 == d:
			print('YES')
		else:
			print('NO')
	elif n * m - 1 == d:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = [int(_) for _ in input().split()]
	print('YNEOS'[n - 1 + n * (m - 1) != k::2])


t = int(input())
while t > 0:
	lst = input()
	(n, m, k) = lst.split(' ')
	n = int(n)
	m = int(m)
	k = int(k)
	if n * m - 1 == k:
		print('YES')
	else:
		print('NO')
	t -= 1


def f(n, m, k):
	if k == n * m - 1:
		return 'YES'
	else:
		return 'NO'
t = int(input())
l = []
for i in range(t):
	(n, m, k) = map(int, input().split())
	s = f(n, m, k)
	l.append(s)
for i in l:
	print(i)


n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	if x[0] == 1:
		if x[1] - x[0] == x[2]:
			print('YES')
		else:
			print('NO')
	elif x[1] == 1:
		if x[0] - x[1] == x[2]:
			print('YES')
		else:
			print('NO')
	elif x[0] * x[1] - 1 == x[2]:
		print('YES')
	else:
		print('NO')


k = int(input())
for _ in range(k):
	(x, y, m) = map(int, input().split())
	if x * y - 1 == m:
		print('YES')
	else:
		print('NO')


T = int(input())
for testcase in range(1, T + 1):
	(n, m, k) = list(map(int, input().split()))
	if k == n * m - 1:
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys
sys.setrecursionlimit(10 ** 5 + 10000)
for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	l = [[0 for j in range(m)] for i in range(n)]
	v = [[False for j in range(m)] for i in range(n)]

	def isvalid(x, y):
		if x < 0 or x > n - 1 or y < 0 or (y > m - 1):
			return False
		if v[x][y] == True:
			return False
		return True
	dx = [0, 1]
	dy = [1, 0]

	def dfs(x, y, dis):
		v[x][y] = True
		l[x][y] = dis
		for i in range(2):
			if isvalid(x + dx[i], y + dy[i]) and i == 0:
				v[x + dx[i]][y + dy[i]] = True
				l[x + dx[i]][y + dy[i]] = dis + x + 1
				dfs(x + dx[i], y + dy[i], dis + x + 1)
			if isvalid(x + dx[i], y + dy[i]) and i == 1:
				v[x + dx[i]][y + dy[i]] = True
				l[x + dx[i]][y + dy[i]] = dis + y + 1
				dfs(x + dx[i], y + dy[i], dis + y + 1)
	dfs(0, 0, 0)
	if l[n - 1][m - 1] == k:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(n, m, burles) = map(int, input().split())
	needed1 = m - 1
	needed1 += m * (n - 1)
	needed2 = n - 1
	needed2 += n * (m - 1)
	if burles == needed1 or burles == needed2:
		print('YES')
	else:
		print('NO')


inp1 = int(input())
for i in range(inp1):
	(a, b, c) = list(map(int, input().split()))
	if a * b - 1 == c:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = [int(x) for x in input().split()]
	a = m - 1 + m * (n - 1)
	if a == k:
		print('YES')
	else:
		print('NO')


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 itertools import permutations
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
LOGN = 30
alp = 'abcdefghijklmnopqrstuvwxyz'
N = 100000.0 + 1
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, m, k) = list(map(int, stdin.readline().rstrip().split()))
	a = [[0 for c in range(m)] for r in range(n)]
	for i in range(n):
		for j in range(m):
			if j == 0:
				a[i][j] = i
			if j != 0:
				a[i][j] += a[i][j - 1] + (i + 1)
	if a[n - 1][m - 1] == k:
		print('YES')
	else:
		print('NO')


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

def mapIn():
	return map(int, input().split())
for ii in range(int(input())):
	(n, m, k) = mapIn()
	ans = n - 1 + n * (m - 1)
	if ans == k:
		print('YES')
	else:
		print('NO')


for tc in range(int(input())):
	(N, M, K) = map(int, input().split())
	C1 = 1 * (M - 1) + M * (N - 1)
	C2 = 1 * (N - 1) + N * (M - 1)
	(mn, mx) = (min(C1, C2), max(C1, C2))
	print('YES' if mn <= K <= mx else 'NO')


for _ in [*open(0)][1:]:
	(a, b, k) = map(int, _.split())
	print('NYOE S'[k == a * b - 1::2])


t = int(input())
for xx in range(t):
	(n, m, k) = map(int, input().split())
	ni = 1
	mi = 1
	x = abs(m - mi) * ni + abs(n - ni) * m
	if x == k:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a = 1
	b = 1
	ans = m - b + (n - a) * m
	print('YES' if k == ans else 'NO')


for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	a1 = m - 1
	a2 = m * (n - 1)
	fa1 = a1 + a2
	b1 = n - 1
	b2 = n * (m - 1)
	fb1 = b1 + b2
	if fa1 == k or fb1 == k:
		print('YES')
	else:
		print('NO')


import sys

def fi():
	return sys.stdin.readline()
for _ in range(int(fi())):
	(a, b, x) = map(int, fi().split())
	max1 = a - 1 + (b - 1) * a
	min1 = b - 1 + (a - 1) * b
	print(['NO', 'YES'][x >= min(max1, min1) and x <= max(max1, min1)])


for _ in range(int(input())):
	(r, c, k) = map(int, input().split())
	ans = r - 1 + (c - 1) * r
	if ans == k:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(m, n, r) = list(map(int, input().split()))
	if m * n - 1 == r:
		print('YES')
	else:
		print('NO')


def solvecaso():
	(n, m, k) = map(int, input().split())
	if k == n * m - 1:
		return 'YES'
	return 'NO'
casos = int(input())
for caso in range(1, casos + 1):
	result = solvecaso()
	print(f'{result}')


def check(i, j, n, m, k, cost):
	if i == n - 1 and j == m - 1:
		if cost == k:
			return True
		return False
	if i >= n or j >= m:
		return False
	if (i, j, cost) in dp:
		return dp[i, j, cost]
	dp[i, j, cost] = check(i + 1, j, n, m, k, cost + j + 1) or check(i, j + 1, n, m, k, cost + i + 1)
	return dp[i, j, cost]
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	dp = {}
	if check(0, 0, n, m, k, 0):
		print('YES')
	else:
		print('NO')


import math
import string
import random
import sys
from random import randrange
from collections import deque
from collections import defaultdict
from bisect import bisect, bisect_right, bisect_left

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

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
for _ in range(int(data())):
	(n, m, k) = mdata()
	mn = min(m, n)
	mx = max(m, n)
	min_moves = mx - 1 + (mn - 1) * mx
	if min_moves == k:
		print('YES')
	else:
		print('NO')


def solve(n, m, k):
	mink = n * m - 1
	return 'YES' if mink == k else 'NO'
tt = int(input())
while tt > 0:
	tt -= 1
	(n, m, k) = list(map(int, input().split()))
	print(solve(n, m, k))


def check_if_cake(x, y, d):
	diff_x = x - 1
	diff_y = y - 1
	res = diff_x + diff_y * x
	if res == d:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	(x, y, z) = list(map(int, input().split()))
	check_if_cake(x, y, z)


from sys import stdin
input = stdin.readline
from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from math import factorial as f, ceil, gcd, sqrt, log
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as c, permutations as p
from math import factorial as f, ceil, gcd, sqrt, log
mi = lambda : map(int, input().split())
ii = lambda : int(input())
li = lambda : list(map(int, input().split()))
mati = lambda r: [li() for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)

def solve():
	(n, m, k) = mi()
	s = min(n - 1 + n * (m - 1), m - 1 + m * n)
	if s == k:
		print('YES')
	else:
		print('NO')
for _ in range(ii()):
	solve()


for i in range(int(input(''))):
	y = list(input('').split(' '))
	if int(y[2]) == int(y[1]) * int(y[0]) - 1:
		print('YES')
	else:
		print('NO')


def getResult(n1, m1, k):
	global DP
	if k == 0 and n1 == n and (m1 == m):
		return 'YES'
	if n1 > n or m1 > m:
		return 'NO'
	if k <= 0 or not DP[n1][m1]:
		return 'NO'
	result = getResult(n1, m1 + 1, k - n1)
	if result == 'NO':
		result = getResult(n1 + 1, m1, k - m1)
	if result == 'NO':
		DP[n1][m1] = False
	return result
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	DP = [[True for i in range(m + 1)] for i in range(n + 1)]
	result = getResult(1, 1, k)
	print(result)


def travel(n, m, k):
	if n == 1 and m == 1 and (k == 0):
		return 1
	if 1 * (m - 1) + m * (n - 1) == k:
		return 1
	return 0
t = int(input())
while t:
	(n, m, k) = map(int, input().split())
	if travel(n, m, k):
		print('YES')
	else:
		print('NO')
	t -= 1


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, M, K):
	cost = N * M - 1
	if cost == K:
		return 'YES'
	return 'NO'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N, M, K) = [int(x) for x in input().split()]
	ans = solve(N, M, K)
	print(ans)


t = int(input())
for _ in range(t):
	d = 0
	(a, b, c) = map(int, input().split())
	d += a - 1
	d += (b - 1) * a
	if d == c:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(n, m, k) = list(map(int, input().split()))
	if k == 0:
		if n == 1 and m == 1:
			print('yes')
		else:
			print('no')
	elif k == n * (m - 1) + (n - 1):
		print('yes')
	else:
		print('no')


import math

def solve():
	(a, b, c) = map(int, input().split())
	ans = b - 1
	ans = ans + (ans + 1) * (a - 1)
	if ans == c:
		return 'yes'
	return 'no'
for i in range(int(input())):
	print(solve())


for Pythonic__Python in range(int(input())):
	(n, m, b) = map(int, input().split())
	if n - 1 + n * (m - 1) == b:
		print('YES')
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().strip()
for i in range(int(input())):
	(x, y, b) = map(int, input().split())
	print('YES') if x * y - 1 == b else print('NO')


def get_ans(dp, row, col, k, n, m):
	if row >= n or col >= m or k < 0:
		return False
	if row == n - 1 and col == m - 1:
		if k == 0:
			return True
		else:
			return False
	if dp[row][col][k] != -1:
		return dp[row][col][k]
	x = get_ans(dp, row + 1, col, k - col - 1, n, m)
	dp[row][col][k] = x
	if x:
		return True
	y = get_ans(dp, row, col + 1, k - row - 1, n, m)
	dp[row][col][k] = y
	if y:
		return True
	return False
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	dp = [[[-1] * (k + 1)] * m] * n
	x = get_ans(dp, 0, 0, k, n, m)
	if x:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
d = defaultdict(lambda : 0)

def check(a, b):
	ans = a
	ans += b * (a + 1)
	return ans
for i in range(int(input())):
	(n, m, k) = map(int, input().split())
	rx = n - 1
	ry = m - 1
	a = check(rx, ry)
	b = check(ry, rx)
	if a == k or b == k:
		print('YES')
	else:
		print('NO')


k = int(input())
while k > 0:
	l = list(map(int, input().split()))
	n = l[0]
	m = l[1]
	b = l[2]
	ras = m - 1 + m * (n - 1)
	if ras == b:
		print('YES')
	else:
		print('NO')
	k = k - 1


t = int(input())
for j in range(1, t + 1):
	(n, m, k) = map(int, input().split())
	if m - 1 + m * (n - 1) == k or n - 1 + n * (m - 1) == k:
		print('YES')
	else:
		print('NO')


tt = input()
tt = int(tt)
for i in range(tt):
	(r, b, d) = input().split()
	r = int(r)
	b = int(b)
	d = int(d)
	dist = max(r, b) - 1 + max(r, b) * (min(r, b) - 1)
	if dist == d:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m, k) = [int(x) for x in input().split()]
	p = m * (n - 1) + (m - 1)
	if p == k:
		print('Yes')
	else:
		print('No')


import sys
import os.path
from collections import *
import math
import bisect
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = int(input())
while t:
	t -= 1
	(n, m, k) = [int(x) for x in input().split()]
	if k == m * n - 1:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(n, m, k) = map(int, input().split())
	print('no' if m * n - k - 1 else 'yes')


def thecake(a1, a2, n, m, k, sum1):
	while a1 < n:
		sum1 += a2
		a1 += 1
	while a2 < m:
		sum1 += a1
		a2 += 1
	if sum1 == k:
		return True
	else:
		return False
t = int(input())
for i in range(t):
	(n, m, k) = map(int, input().split())
	sum1 = 0
	z = thecake(1, 1, n, m, k, sum1)
	if z == True:
		print('YES')
	else:
		print('NO')


n = int(input())
arr = []
for i in range(0, n):
	(m, n, k) = [int(x) for x in input().split()]
	p = m * (n - 1) + (m - 1)
	if k == p:
		c = 'YES'
	else:
		c = 'NO'
	arr.append(c)
l = len(arr)
for k in range(0, l):
	print(arr[k])


t = int(input())
while t != 0:
	t -= 1
	moi = input()
	a = moi.split()
	y = int(a[1]) - 1
	right = y
	x = int(a[0]) - 1
	down = int(a[1]) * x
	if right + down == int(a[2]):
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m, k) = map(int, input().split())
	if m == 1 and n != 1:
		ans = n - 1
	if n == 1 and m != 1:
		ans = m - 1
	else:
		ans = m - 1 + (n - 1) * m
	if ans == k:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	tmp = a - 1 + a * (b - 1)
	if tmp == c:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t = t - 1
	(n, m, k) = [int(n) for n in input().split()]
	lt = []
	lt.append(n)
	lt.append(m)
	a = min(lt)
	c = max(lt)
	if n == m:
		if (n + 1) * (m - 1) == k:
			print('Yes')
		else:
			print('No')
	else:
		b = (a + 1) * (a - 1)
		d = c - a
		e = d * a
		f = b + e
		if f == k:
			print('Yes')
		else:
			print('No')


import math

def freq(n, m, x, y, cost, k):
	if x == n and y == m and (cost == k):
		return True
	if x < n and cost + y <= k:
		return freq(n, m, x + 1, y, cost + y, k)
	if y < m and cost + x <= k:
		return freq(n, m, x, y + 1, cost + x, k)
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	boo = freq(n, m, 1, 1, 0, k)
	if boo == True:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	linha = input()
	linha = linha.split()
	n = float(linha[0])
	m = float(linha[1])
	k = float(linha[2])
	a = m * (n - 1) + m - 1
	if a == k:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(N, M, K) = map(int, input().split())
	k = N - 1 + (M - 1) * N
	print('YES' if k == K else 'NO')


def solve(n, m, k):
	a = m - 1 + m * (n - 1)
	b = n - 1 + n * (m - 1)
	(xmin, xmax) = (min(a, b), max(a, b))
	return 'YES' if xmin <= k <= xmax else 'NO'
for _ in range(int(input())):
	(n, m, k) = map(int, input().split())
	print(solve(n, m, k))