#P1258. Destination

Destination

题目描述

There is a n×mn×m grid. You are standing at cell (1,1)(1,1) and your goal is to finish at cell (n,m)(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)(x,y). You can:

  • move right to the cell (x,y+1)(x,y+1) — it costs xx yuan;
  • move down to the cell (x+1,y)(x+1,y) — it costs yy yuan.

Can you reach cell (n,m)(n,m) spending exactly kk yuan?

输入格式

The first line contains the single integer t(1t100)t (1≤t≤100) — the number of test cases.

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

输出格式

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

样例

6 
1 1 0 
2 2 2 
2 2 3 
2 2 4 
1 4 3 
100 100 100
YES 
NO 
YES 
NO 
YES 
NO

提示

In the first test case, you are already in the final cell, so you spend 00 yuan.

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

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