Polycarp found a rectangular table consisting of $n$ rows and $m$ columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns":

cells are numbered starting from one;

cells are numbered from left to right by columns, and inside each column from top to bottom;

number of each cell is an integer one greater than in the previous cell.

For example, if $n = 3$ and $m = 5$, the table will be numbered as follows:

$$ \begin{matrix} 1 & 4 & 7 & 10 & 13 \\ 2 & 5 & 8 & 11 & 14 \\ 3 & 6 & 9 & 12 & 15 \\ \end{matrix} $$

However, Polycarp considers such numbering inconvenient. He likes the numbering "by rows":

cells are numbered starting from one;

cells are numbered from top to bottom by rows, and inside each row from left to right;

number of each cell is an integer one greater than the number of the previous cell.

For example, if $n = 3$ and $m = 5$, then Polycarp likes the following table numbering: $$ \begin{matrix} 1 & 2 & 3 & 4 & 5 \\ 6 & 7 & 8 & 9 & 10 \\ 11 & 12 & 13 & 14 & 15 \\ \end{matrix} $$

Polycarp doesn't have much time, so he asks you to find out what would be the cell number in the numbering "by rows", if in the numbering "by columns" the cell has the number $x$?


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$). Then $t$ test cases follow.

Each test case consists of a single line containing three integers $n$, $m$, $x$ ($1 \le n, m \le 10^6$, $1 \le x \le n \cdot m$), where $n$ and $m$ are the number of rows and columns in the table, and $x$ is the cell number.

Note that the numbers in some test cases do not fit into the $32$-bit integer type, so you must use at least the $64$-bit integer type of your programming language.


-----Output-----

For each test case, output the cell number in the numbering "by rows".


-----Examples-----

Input
5
1 1 1
2 2 3
3 5 11
100 100 7312
1000000 1000000 1000000000000
Output
1
2
9
1174
1000000000000


-----Note-----

None

Difficulty: EASY

Solutions:
for _ in range(int(input())):
	(n, m, x) = list(map(int, input().split()))
	x -= 1
	col = x // n
	row = x % n
	print(row * m + col + 1)


import math
import sys
import collections
import bisect
import time

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(n, m, x) = get_ints()
	col_no = x // n
	row_no = x - n * (x // n)
	if row_no == 0:
		row_no = n
		col_no -= 1
	ans = (row_no - 1) * m + col_no + 1
	print(ans)


for s in [*open(0)][1::1]:
	tem = s.split()
	for (po, i) in enumerate(tem):
		tem[po] = int(i)
	a = tem[2]
	b = a // tem[0]
	c = a % tem[0]
	if c == 0:
		c = tem[0]
		b -= 1
	print((c - 1) * tem[1] + b + 1)


e = int(input())
t = []
for i in range(e):
	(n, m, x) = map(int, input().split())
	t.append([n, m, x])
for j in range(e):
	N = t[j][0]
	M = t[j][1]
	X = t[j][2]
	X -= 1
	d_c = X // N
	d_r = X % N
	print(d_r * M + d_c + 1)


import re

def main():
	for i in range(int(input())):
		(n, m, x) = map(int, input().split(' '))
		(s, z) = ((x - 1) % n + 1, (x - 1) // n + 1)
		print((s - 1) * m + z)
main()


import math
from collections import defaultdict
DEBUG = True

def log(*args, **kwargs):
	if DEBUG:
		print(*args, **kwargs)

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

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

def rs():
	return input()

class Solution:

	def __init__(self):
		pass

	def run(self):
		(n, m, x) = rl()
		(r, c) = ((x - 1) % n, (x - 1) // n)
		return r * m + c + 1
t = int(input())
s = Solution()
for i in range(t):
	print(s.run())


inputList = []
outputList = []
t = int(input())
for i in range(t):
	inputList.append(input())
for i in range(len(inputList)):
	inputList[i] = inputList[i].split()
for i in range(len(inputList)):
	for j in range(3):
		inputList[i][j] = int(inputList[i][j])
for i in range(len(inputList)):
	if inputList[i][2] % inputList[i][0] != 0:
		outputList.append(int(inputList[i][2] / inputList[i][0]) + 1 + (inputList[i][2] % inputList[i][0] - 1) * inputList[i][1])
	else:
		outputList.append(inputList[i][2] / inputList[i][0] + (inputList[i][0] - 1) * inputList[i][1])
for i in outputList:
	print(int(i))


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	print((x + n - 1) // n + m * (x % n - 1 + (n if x % n == 0 else 0)))


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial, sqrt
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, accumulate
from bisect import *
from functools import reduce
from operator import mul
star = lambda x: print(' '.join(map(str, x)))
grid = lambda r: [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
INF = float('inf')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import sys
from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil

def st():
	return list(stdin.readline().strip())

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def pr(n):
	return stdout.write(str(n) + '\n')

def return_divisors(n):
	ll = []
	for i in range(1, n + 1):
		if n % i == 0:
			ll.append(i)
	return ll

def calc(n):
	return sum([int(i) for i in list(str(n))])

def solve():
	(n, m, x) = invr()
	k = x // n
	k1 = x % n
	if k1 == 0:
		tt = (n - 1) * m
		print(tt + k)
	else:
		print((k1 - 1) * m + (k + 1))
t = 1
t = inp()
for _ in range(t):
	global g
	g = defaultdict(list)
	solve()


def solve():
	(n, m, x) = map(int, input().split())
	x -= 1
	col = int(x / n)
	row = int(x % n)
	print(row * m + col + 1)
n = int(input())
for i in range(n):
	solve()


c = int(input())
ls = []
ls1 = []
for i in range(c):
	k = input().split()
	for z in k:
		ls.append(int(z))

def main(n, m, x):
	c = x % n
	d = x // n + 1
	if c == 0:
		q = d + (n - 1) * m - 1
	else:
		q = d + (c - 1) * m
	print(q)
o = len(ls)
for i in range(o):
	if i % 3 == 0:
		ls1.append(i)
for i in ls1:
	main(ls[i], ls[i + 1], ls[i + 2])


for s in [*open(0)][1:]:
	(n, m, x) = map(int, s.split())
	x -= 1
	print(x % n * m + x // n + 1)


n1 = int(input())
arr1 = []
for i in range(n1):
	arr = list(map(int, input().strip().split()))
	arr1.append(arr)
for i in range(n1):
	n = arr1[i][0]
	k = arr1[i][1]
	l = arr1[i][2]
	x = l // n
	y = l % n - 1
	if l > x and y != -1:
		z = x + 1 + k * y
		print(z)
	elif l < x or l == n:
		z = 1 + k * (l - 1)
		print(z)
	elif y == -1 and n * k != l and (n != l):
		z = x + (n - 1) * k
		print(z)
	elif n * k == l:
		print(l)


import math
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	if x % n == 0:
		row = n
	else:
		row = x % n
	column = math.ceil(x / n)
	print((row - 1) * m + column)


from sys import stdin
import math
testcase = int(stdin.readline())
for i in range(testcase):
	table = list(map(int, stdin.readline().split()))
	X = math.ceil(table[2] / table[0])
	Y = table[2] - (X - 1) * table[0]
	print(table[1] * (Y - 1) + X)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	d = x % n if x % n else n
	if x % n != 0:
		print(m * (d - 1) + x // n + 1)
	else:
		print(m * (d - 1) + x // n)


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	if x / n == x // n:
		a = x // n
	else:
		a = x // n + 1
	b = x % n
	if b == 0:
		b = n
	ans = m * (b - 1) + a
	print(ans)


for t in range(int(input())):
	(n, m, k) = map(int, input().split())
	k -= 1
	x = k // n
	y = k % n
	print(y * m + x + 1)


from math import ceil

def number(n, m, x):
	r = (x - 1) % n + 1
	c = ceil(x / n)
	num = (r - 1) * m + c
	return num
t = int(input())
answer = []
for _ in range(t):
	(n, m, x) = map(int, input().split())
	answer.append(number(n, m, x))
for i in answer:
	print(i)


for _ in range(int(input())):
	[n, m, x] = [int(i) for i in input().split(' ')]
	c = x // n
	r = x - c * n
	if r == 0:
		r = n
		c -= 1
	ans = (r - 1) * m
	if ans < 0:
		ans = 0
	ans += c + 1
	print(ans)


for _ in [0] * int(input()):
	(n, m, x) = map(int, input().split())
	x -= 1
	(i, j) = (x // n, x % n)
	print(i + j * m + 1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	c = (x - 1) // n
	r = (x - 1) % n
	ans = r * m + c
	print(ans + 1)


import math
t = int(input())
A = []
for i in range(t):
	a = [int(p) for p in input().split()]
	A.append(a)
for i in range(t):
	(n, m, x) = A[i]
	lmao = math.ceil(x / n)
	sisa = x % n
	if sisa == 0:
		print(m * (n - 1) + lmao)
	else:
		print((sisa - 1) * m + lmao)


import sys
import math
import bisect
import collections
input = sys.stdin.readline

def inp():
	return int(input())

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

def inpstrlist():
	s = input()
	return list(s[:len(s)])

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

def printlist(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')
for _ in range(inp()):
	(n, m, k) = invr()
	(y, x) = ((k - 1) // n, (k - 1) % n)
	ans = m * x + y + 1
	print(ans)


for x in range(int(input())):
	(n, m, x) = map(int, input().split())
	xm = x // n
	if x % n == 0:
		xm -= 1
	y = x - xm * n
	print((y - 1) * m + xm + 1)


from math import ceil

def main():
	import sys
	input = sys.stdin.readline
	for _ in range(int(input())):
		(n, m, x) = map(int, input().split())
		c = ceil(x / n)
		r = (x - 1) % n + 1
		print(m * (r - 1) + c)
main()


import math
t = int(input())
for z in range(t):
	(n, m, x) = map(int, input().split())
	if x % n != 0:
		print((x % n - 1) * m + math.ceil(x / n))
	else:
		print((n - 1) * m + math.ceil(x / n))


t = int(input())
lst = []
for i in range(0, t):
	dim = input()
	bob = dim.split()
	n = int(bob[0])
	m = int(bob[1])
	x = int(bob[2])
	column = (x - 1) // n
	row = (x - 1) % n
	lst.append(row * m + column + 1)
for i in lst:
	print(i)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c) = [int(x) for x in input().split()]
	if c % a:
		print(b * (c % a - 1) + (a + c - 1) // a)
	else:
		print(b * (a - 1) + (a + c - 1) // a)


t = int(input())
for _t in range(t):
	(n, m, x) = map(int, input().split())
	x = x - 1
	(i, j) = (x % n, x // n)
	print(i * m + j + 1)


n = int(input())
ans = list()
for i in range(n):
	inp = input().split(' ')
	modulus = int(inp[2]) % int(inp[0])
	division = int(int(inp[2]) / int(inp[0]))
	if modulus == 0:
		modulus = int(inp[0])
		division -= 1
	ans.append(int(inp[1]) * (modulus - 1) + (division + 1))
for i in ans:
	print(i, end='\n')


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

def main():
	t = int(input())
	for z in range(t):
		q = list(map(int, input().split()))
		ans = q[1] * (q[0] - (q[0] * math.ceil(q[2] / q[0]) - q[2])) - (q[1] - math.ceil(q[2] / q[0]))
		print(ans)
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')
main()


t = int(input())
lis = []
out = []
for i in range(t):
	lis.append([int(j) for j in input().split()])
	count = 0
	if lis[i][2] % lis[i][0] == 0:
		a = lis[i][0]
	else:
		a = lis[i][2] % lis[i][0]
	if lis[i][2] % lis[i][0] == 0:
		b = lis[i][2] // lis[i][0]
	else:
		b = lis[i][2] // lis[i][0] + 1
	count = (a - 1) * lis[i][1] + b
	out.append(count)
for i in out:
	print(i)


t = int(input())
for i in range(t):
	(n, m, x) = map(int, input().split())
	r = x % n
	if r == 0:
		r = n
	c = x // n
	if x / n != int(x / n):
		c += 1
	print(c + (r - 1) * m)


for i in range(int(input())):
	(n, m, x) = map(int, input().split())
	c = n
	a = x // n
	if x % n != 0:
		a += 1
		c = x % n
	print(m * (c - 1) + a)


import math
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	acolumn = math.ceil(x / n) - 1
	arow = x - acolumn * n - 1
	print(arow * m + acolumn + 1)


import sys
import math
tc = int(sys.stdin.readline())
for _ in range(tc):
	(n, m, x) = map(int, sys.stdin.readline().rstrip().split())
	k = math.ceil(x / n)
	(row, col) = (x - n * (k - 1), k)
	print((row - 1) * m + col)


n = int(input())
for i in range(0, n):
	p = input().rstrip().split(' ')
	N = int(p[0])
	m = int(p[1])
	x = int(p[2])
	I = 1
	J = N + 1
	A = x // N
	if x % N == 0:
		A -= 1
	B = A * N
	row = x - B
	C = B // N
	col = C + 1
	row = 1 + (row - 1) * m
	ans = row + (col - 1)
	print(ans)


def find_cell(queries):
	pass
	n = queries[0]
	m = queries[1]
	val = queries[2]
	rem = val % n
	div = val // n
	i = -1
	j = -1
	if rem == 0 and div != 0:
		pass
		i = n - 1
		j = div - 1
	elif rem != 0 and div != 0:
		pass
		i = rem - 1
		j = div
	else:
		pass
		i = rem - 1
		j = 0
	return i * m + j + 1
s = int(input().strip())
queries = []
for i in range(s):
	k = [int(l) for l in input().strip().split()]
	queries.append(k)
for i in range(s):
	print(find_cell(queries[i]))


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	(c, r) = (x // n + 1, x % n)
	if r == 0:
		c -= 1
		r = n
	print((r - 1) * m + c)


f = int(input())
for q in range(f):
	(n, m, a) = map(int, input().split())
	x = a // n
	y = a % n
	if a % n > 0:
		x += 1
		y -= 1
	else:
		y = n - 1
	print(y * m + x)


b = [list(map(int, input().split())) for i in range(int(input()))]
print(*[(a[2] - 1) % a[0] * a[1] + (a[2] + a[0] - 1) // a[0] for a in b], sep='\n')


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	(k, l) = divmod(c, a)
	if l == 0:
		t = (a - 1) * b
		t += k
		print(t)
	else:
		t = (l - 1) * b
		t += k + 1
		print(t)


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

def si():
	return input().rstrip()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	for _ in range(ii()):
		(n, m, x) = mi()
		x1 = ceil(x, n)
		x %= n
		if x == 0:
			x = n
		print((x - 1) * m + x1)
if file:
	if path.exists('tmp/input.txt'):
		sys.stdin = open('tmp/input.txt', 'r')
		sys.stdout = open('tmp/output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


import collections
import math
from sys import stdin

def ip():
	return [int(i) for i in stdin.readline().split()]

def sp():
	return [str(i) for i in stdin.readline().split()]
t = int(input())
for _ in range(t):
	(n, m, x) = ip()
	if x % n == 0:
		col = x // n
		row = n
	else:
		col = x // n + 1
		row = x % n
	ans = row * m - (m - col)
	print(ans)


num = int(input())
lsn = []
lsm = []
lsx = []
for i in range(num):
	(n, m, x) = map(int, input().split())
	lsn.append(n)
	lsm.append(m)
	lsx.append(x)
for i in range(num):
	a = lsx[i] % lsn[i]
	if a == 0:
		a += lsn[i]
	b = lsx[i] // lsn[i] + 1
	if lsx[i] % lsn[i] == 0:
		b -= 1
	c = (a - 1) * lsm[i] + b
	print(c)


__version__ = '0.1'
__date__ = '2021-03-25'
import sys

def solve(n, m, x) -> int:
	col = (x - 1) // n + 1
	row = x % n
	if row == 0:
		row = n
	row -= 1
	return m * row + col

def main(argv=None):
	t = int(input())
	for _ in range(t):
		(n, m, x) = map(int, input().split())
		print(solve(n, m, x))
	return 0
STATUS = main()
sys.exit(STATUS)


import math
import operator as op
from functools import reduce
from collections import defaultdict
from math import comb
from sys import stdout
NO = 'NO'
YES = 'YES'
MOD = 1000000007

def input_int():
	return int(input())

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

def input_list_int():
	return list(map(int, input_list()))

def z_func(s):
	n = len(s)
	z = [0] * n
	l = r = 0
	for i in range(1, n):
		if r >= i:
			z[i] = min(z[i - l], r - i + 1)
		while z[i] + i < n and s[z[i]] == s[z[i] + i]:
			z[i] += 1
		if i + z[i] - 1 > r:
			l = i
			r = i + z[i] - 15
	return z
global_ans = []

def pr(a):
	global_ans.append(a)

def solve():
	(n, m, x) = input_list_int()
	t2 = x % n
	if t2 == 0:
		t2 = n
	t1 = math.ceil(x / n)
	pr(t2 * m - (m - t1))
query_count = 1
query_count = input_int()
while query_count:
	query_count -= 1
	solve()
for global_ans_line in global_ans:
	print(global_ans_line)


t = int(input())
answer = []
for i in range(t):
	numbers = list(map(int, input().split(' ')))
	if numbers[2] % numbers[0] == 0:
		answer.append((numbers[0] - 1) * numbers[1] + numbers[2] // numbers[0])
	else:
		answer.append((numbers[2] % numbers[0] - 1) * numbers[1] + numbers[2] // numbers[0] + 1)
for i in answer:
	print(i)


import sys
import math

def fn(n, m, x):
	if x // n == x / n:
		j = x // n
		i = n
	else:
		j = x // n + 1
		i = x % n
	x1 = (i - 1) * m + j
	return x1
input = sys.stdin.read()
data = list(map(int, input.split()))
t = data[0]
l = 0
for i in range(t):
	n = data[l + 1]
	m = data[l + 2]
	x = data[l + 3]
	l = l + 3
	print(fn(n, m, x))


t = int(input())
liste = []
for _ in range(t):
	(n, m, x) = [int(i) for i in input().split()]
	if n * m == x:
		liste.append(x)
	else:
		if x % n == 0:
			d = n - 1
			c = x // n
		else:
			d = x % n - 1
			c = x // n + 1
		a = c + d * m
		liste.append(a)
for x in liste:
	print(x)


import math
answers = []

def solve(n, m, x):
	col = math.ceil(x / n)
	row = None
	if x % n == 0:
		row = n
	else:
		row = x % n
	count = 0
	count += (row - 1) * m
	count += col
	answers.append(count)
T = int(input())
while T:
	(n, m, x) = [int(x) for x in input().split()]
	solve(n, m, x)
	T -= 1
for ans in answers:
	print(ans)


from sys import stdin, stdout
import math

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

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

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

def si():
	return stdin.readline()
for _ in range(ii()):
	(n, m, x) = mi()
	a = x % n
	if a == 0:
		a = n - 1
	else:
		a = a - 1
	b = math.ceil(x / n)
	print(m * a + b)


t = int(input())
natija = []
for i in range(t):
	(n, m, x) = input().split(' ')
	(n, m, x) = (int(n), int(m), int(x))
	if x % n == 0:
		satr = n
		ustun = x // n
	else:
		satr = x - x // n * n
		ustun = x // n + 1
	natija.append((satr - 1) * m + ustun)
for i in range(t):
	print(natija[i])


T = int(input())
NMX = [list(map(int, input().split())) for _ in range(T)]
for nmx in NMX:
	(n, m, x) = nmx
	H = (x - 1) // n
	W = (x - 1) % n
	print(W * m + H + 1)


import math
import sys
from functools import reduce
import decimal
sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP

def rounding(n):
	return int(decimal.Decimal(f'{n}').to_integral_value())

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

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

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
for _ in range(int(inp())):
	(n, m, x) = map_inp(int)
	temp = (x - 1) // n
	rem = x % n
	if rem == 0:
		print(m * (n - 1) + temp + 1)
	else:
		print(m * (rem - 1) + temp + 1)


from sys import stdin, stdout
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial
for _ in range(it()):
	(n, m, x) = mp()
	r = ceil(x / n)
	c = x % n if x % n else n
	print((c - 1) * m + r)


from collections import Counter
from functools import lru_cache
t = int(input())
for _ in range(t):
	(n, m, x) = [int(i) for i in input().split()]
	col = x // n
	row = x % n
	if row == 0:
		row = n - 1
		col -= 1
	else:
		row -= 1
	val = row * m + col + 1
	print(val)


t = int(input())
rez = []
for i in range(t):
	(n, m, x) = map(int, input().split())
	if x % n == 0:
		stroka = n
		stolbec = x // n
	else:
		stroka = x % n
		stolbec = x // n + 1
	rez += [(stroka - 1) * m + stolbec]
for i in rez:
	print(i)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree2:

	def __init__(self, data, default=3000006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 10, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

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

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor, t):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += t
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += t
		self.temp.data = pre_xor

	def query(self, p, l):
		ans = 0
		self.temp = self.root
		for i in range(31, -1, -1):
			val = p & 1 << i
			val1 = l & 1 << i
			if val1 == 0:
				if val == 0:
					if self.temp.left and self.temp.left.count > 0:
						self.temp = self.temp.left
					else:
						return ans
				elif self.temp.right and self.temp.right.count > 0:
					self.temp = self.temp.right
				else:
					return ans
			elif val != 0:
				if self.temp.right:
					ans += self.temp.right.count
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				else:
					return ans
			else:
				if self.temp.left:
					ans += self.temp.left.count
				if self.temp.right and self.temp.right.count > 0:
					self.temp = self.temp.right
				else:
					return ans
		return ans
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	j = (x - 1) // n
	i = (x - 1) % n
	print(m * i + j + 1)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, m, x) = map(int, stdin.readline().split())
	a = x // n
	if x % n != 0:
		a += 1
	b = x % n
	if b == 0:
		b = n
	(a, b) = (b - 1, a - 1)
	c = a * m + b
	print(c + 1)


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	x -= 1
	(r, q) = divmod(x, n)
	res = q * m + r + 1
	print(res)


import sys

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

def solve(n, m, x):
	b = x // n
	if x % n:
		b += 1
	a = (x - 1) % n
	return a * m + b
t = int(input())
for i in range(t):
	(m, n, x) = get_ints()
	print(solve(m, n, x))


t = int(input())
inpl = []
for i in range(t):
	s = tuple(input().split())
	(n, m, x) = (int(s[0]), int(s[1]), int(s[2]))
	inpl.append([n, m, x])
for i in range(t):
	n = inpl[i][0]
	m = inpl[i][1]
	x = inpl[i][2]
	if x % n == 0:
		b = x // n
	else:
		b = x // n + 1
	c = x % n
	if c == 0:
		c = n
	pos = (c - 1) * m + b
	print(pos)


from collections import Counter
import math

def solve():
	(n, m, d) = list(map(int, input().split()))
	array = []
	main = []
	col = math.ceil(d / n)
	(k, j, i, u) = (1, 0, 0, 0)
	return col + (d - (col - 1) * n - 1) * m
for i in range(int(input())):
	print(solve())


t = int(input())
for q in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	(n, m, x) = (L[0], L[1], L[2])
	print(m * ((x - 1) % n) + (x - 1) // n + 1)


import sys
from collections import *
from functools import lru_cache
from math import *
N = int(1000000000.0 + 7)

def read() -> list:
	return list(map(int, input().strip().split(' ')))

def check(a, b):
	return (a * a - b) ** 2 == a * a + b * b
n2 = int(input())
st = set()
for i in range(n2):
	(n, m, x) = read()
	(xx, yy) = ((x - 1) % n + 1, (x - 1) // n + 1)
	print(xx * m - (m - yy))


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)

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

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict
import math
t = I()
for i in range(t):
	(n, m, x) = lint()
	col = (x - 1) // n
	row = (x - 1) % n
	print(row * m + col + 1)


import math
t = int(input())
while t != 0:
	(n, m, x) = map(int, input().split())
	if x % n == 0:
		i = n
	else:
		i = x % n
	j = math.ceil((x - i + n) / n)
	r = m * (i - 1) + j
	print(r)
	t -= 1


import math

def solve(n, m, x):
	col_no = (x - 1) // n
	row_no = (x - 1) % n
	ans = row_no * m + col_no + 1
	return ans
t = int(input())
for i in range(t):
	(n, m, x) = map(int, input().split())
	print(solve(n, m, x))


from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	for t in range(t):
		nmx = [int(x) for x in stdin.readline().split()]
		idash = nmx[-1] % nmx[0]
		if idash == 0:
			idash = nmx[0]
		jdash = (nmx[-1] - idash) / nmx[0] + 1
		y = nmx[1] * (idash - 1) + jdash
		print(int(y))
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(m, n, x) = map(int, input().split())
	(k, r) = divmod(x - 1, m)
	y = r * n + k + 1
	print(y)


from sys import stdin, stdout
from math import ceil

def main():
	t = int(stdin.readline())
	for _ in range(t):
		(n, m, x) = map(int, stdin.readline().split(' '))
		x = x - 1
		q = x // n
		r = x % n
		y = r * m + q
		stdout.write(str(y + 1) + '\n')
main()


import sys
input = sys.stdin.readline
t = int(input())
for i1 in range(t):
	(n, m, x) = map(int, input().split())
	cnt = x % n
	cnt1 = x // n
	if cnt == 0:
		print(m * n - m + cnt1)
		continue
	k = (cnt - 1) * m + cnt1 + 1
	print(k)


def STR():
	return list(input())

def INT():
	return int(input())

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

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

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

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
for tt in range(INT()):
	(n, m, x) = MAP()
	col = ceil(x / n)
	row = x % n
	if row == 0:
		row = n
	k1 = (row - 1) * m + col
	print(k1)


import math, random, time
from collections import *
from itertools import *

def ass(a, b):
	print(f'Assertion error: {a} != {b}' if a != b else 'OK')

def nr():
	return int(input())

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

def nrss(n):
	return [nrs() for _ in range(n)]

def word():
	return input()

def words():
	return [w for w in input().split()]

def rx():
	return [s.rstrip() for s in open(0)]

def nrx(s):
	return int(s)

def nrxs(s):
	return [int(i) for i in s.split()]

def wrx(s):
	return s

def wrxs(s):
	return [w for w in s.split()]

def dump(lst):
	for (i, item) in enumerate(lst):
		print(i, item)

def binsearch(arr, a, b):
	m = (a + b) // 2
	if a >= b:
		return a - 1 if arr[a] == 0 else a
	return binsearch(arr, a, m - 1) if arr[m] == 0 else binsearch(arr, m + 1, b)

def gcd(x, y):
	return x if y == 0 else gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def sign(a):
	return 0 if a == 0 else int(a / abs(a))

def f(n, m, x):
	x = x - 1
	(i, j) = (x % n, x // n)
	return 1 + j + i * m
for s in rx()[1::1]:
	(n, m, x) = nrxs(s)
	print(f(n, m, x))


import math

def find_ans(n, m, x):
	row = (x - 1) % n
	col = math.ceil(x / n)
	return row * m + col
test_cases = int(input())
ans = []
for i in range(test_cases):
	(n, m, x) = list(map(int, input().split()))
	ans.append(find_ans(n, m, x))
for i in ans:
	print(i)


def solve(n, m, x):
	row = x % n
	if row == 0:
		row = n
	if n * m == x:
		return n * m
	return (x - row) // n + 1 + (row - 1) * m
(ans, t) = ([], int(input()))
for i in range(t):
	inps = input().split()
	(n, m, x) = (int(inps[0]), int(inps[1]), int(inps[2]))
	ans.append(solve(n, m, x))
for i in range(t):
	print(ans[i])


import sys
from math import ceil
input = sys.stdin.readline
output = sys.stdout.write

def main():
	tests = int(input().rstrip())
	for i in range(tests):
		(row, column, x) = map(int, input().rstrip().split())
		col_ = ceil(x / row)
		ro_ = x - row * col_ + row
		ans = column * (ro_ - 1) + col_
		output(str(ans))
		output('\n')
main()


import sys

def solve(n, m, x):
	x -= 1
	col = x // n
	row = x % n
	return str(row * m + col + 1)

def main():
	input = sys.stdin.readline
	print = sys.stdout.write
	res = ''
	t = int(input())
	for _ in range(t):
		(n, m, x) = map(int, input().split())
		sub_res = solve(n, m, x)
		res += sub_res + '\n'
	print(res)
main()


test = int(input())
for i in range(test, 0, -1):
	arr = input().split(' ')
	n = int(arr[0])
	m = int(arr[1])
	t = int(arr[2])
	answer = (t - 1) // n + 1
	if t % n == 0:
		answer += (n - 1) * m
	else:
		answer += (t % n - 1) * m
	print(answer)


import math

def compute(rows, columns, x):
	j = math.ceil(x / rows)
	i = x % rows
	if i == 0:
		i = rows
	return (i - 1) * columns + j

def main():
	T = int(input())
	result = []
	for i in range(T):
		instr = input().split()
		r = int(instr[0])
		c = int(instr[1])
		x = int(instr[2])
		result.append(compute(r, c, x))
	for i in range(0, T):
		print(result[i])
main()


t = int(input())
for z in range(t):
	(n, m, x) = [int(q) for q in input().split()]
	r = (x - 1) % n
	c = (x - 1) // n
	print(r * m + c + 1)


for _ in range(int(input())):
	(n, m, x) = [int(i) for i in input().split(' ')]
	i = (x - 1) % n
	j = (x - 1) // n
	print(j + m * i + 1)


import math
for case in range(int(input())):
	(n, m, x) = [int(x) for x in input().split()]
	c = math.ceil(x / n)
	x %= n
	if x == 0:
		r = n
	else:
		r = x
	ans = (r - 1) * m + c
	print(ans)


import math
t = int(input())
while t > 0:
	(n, m, x) = map(int, input().split())
	vtc = int(math.ceil(x / n))
	vtd = x % n if x % n != 0 else n
	if n == 1:
		vtd = 1
	if m == 1:
		vtc = 1
	vt = m * (vtd - 1) + vtc
	print(vt)
	t -= 1


import math
t = int(input())
for _ in range(t):
	num = [int(x) for x in input().split()]
	col = math.ceil(num[2] / num[0])
	row = num[2] - (col - 1) * num[0]
	ans = (row - 1) * num[1] + col
	print(ans)


def main():
	from sys import stdin, stdout
	rl = stdin.readline
	wl = stdout.write
	for _ in range(int(rl())):
		(n, m, x) = map(int, rl().split())
		a = (x - 1) % n
		b = (x - 1) // n
		r = 1 + m * a + b
		wl(str(r) + '\n')
main()


from itertools import accumulate as ac
from collections import Counter as cc
from bisect import bisect_left as bsl
from bisect import bisect as bs
from math import factorial as f
from collections import *
from itertools import *
from string import *
from bisect import *
from queue import *
from heapq import *
from math import *
from sys import *
from re import *

def fast():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
num = int(z())
for _ in range(num):
	(r, c, x) = zzz()
	pos_x = ceil(x / r)
	pos_y = r - (r * pos_x - x)
	print(pos_x + (pos_y - 1) * c)


t = int(input())
for i in range(t):
	(n, m, x) = [int(i) for i in input().split()]
	p = (x - 1) // n
	q = (x - 1) % n
	print(q * m + p + 1)


from math import ceil
results = []
test = int(input())
for case in range(test):
	crx = input()
	(row, col, x) = crx.split(' ')
	col = int(col)
	row = int(row)
	x = int(x)
	row_no = x % row
	if row_no == 0:
		row_no = row
	col_no = ceil(x / row)
	row_way = col * (row_no - 1) + col_no
	results.append(row_way)
for result in results:
	print(result)


for _ in range(int(input())):
	(n, m, x) = [int(x) for x in input().split()]
	i = x % n
	j = x // n
	if i == 0:
		i = n - 1
		j = j - 1
	else:
		i = i - 1
	print(i * m + j + 1)


def solve():
	(n, m, x) = map(int, input().split())
	x -= 1
	stroka = x % n
	stolb = x // n
	print(stroka * m + stolb + 1)
t = int(input())
while t:
	solve()
	t -= 1


import math
T = int(input())

def main(obj):
	n = obj.n
	m = obj.m
	x = obj.x
	col = int(math.ceil(x / n))
	if n == 1 or m == 1:
		return x
	row = (x - 1) % n + 1
	return (row - 1) * m + col

class case:

	def __init__(self, line):
		self.line = [int(i) for i in line.split()]
		self.n = self.line[0]
		self.m = self.line[1]
		self.x = self.line[2]
cases = []
for i in range(T):
	line = input()
	cases.append(case(line))
for i in range(T):
	print(main(cases[i]))


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	col = x // n
	if x % n == 0:
		col -= 1
	row = x - col * n
	row -= 1
	print(row * m + col + 1)


import sys
lines = sys.stdin.readlines()
number_of_testcases = int(lines[0])
for i in range(number_of_testcases):
	(n, m, x) = list(map(int, lines[i + 1].strip().split(' ')))
	divisor = (x - 1) // n + 1
	remainder = (x - 1) % n + 1
	output_now = (remainder - 1) * m + divisor
	print(output_now)


import sys
from math import *
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m, x) = map(int, input().split())
	if x % n == 0:
		a = n
	else:
		a = x % n
	print(m * (a - 1) + ceil(x / n))


def strangeTable(n, m, x):
	x -= 1
	row = x % n
	col = int(x / n)
	res = row * m + col + 1
	print(res)
	return
tc = int(input())
for _ in range(0, tc):
	(n, m, x) = input().split()
	n = int(n)
	m = int(m)
	x = int(x)
	strangeTable(n, m, x)


for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	if x % n == 0:
		k = n
		j = 0
	else:
		k = x % n
		j = 1
	row = k - 1
	col = x // n + j
	ans = row * m + col
	print(ans)


t = int(input())
for i in range(0, t):
	(n, m, x) = [int(x) for x in input().split()]
	a = (x - 1) % n
	b = int((x - 1) / n)
	c = a * m
	ans = c + b + 1
	print(ans)


from math import ceil
for t in range(int(input())):
	(n, m, k) = map(int, input().split())
	r = k % n
	if r == 0:
		r = n
	c = ceil(k / n)
	r -= 1
	print(r * m + c)


def somefunc(n, m, x):
	if n == m and n == 1:
		return x
	ans = 0
	row = 0
	if x % n == 0:
		row = x / n
	else:
		row = x // n + 1
	col = x % n
	if col == 0:
		col = n
	ans = int(m * (col - 1))
	ans += row
	return int(ans)
for t in range(int(input())):
	(n, m, x) = map(int, input().split())
	print(somefunc(n, m, x))


def main():
	for _ in range(int(input())):
		(n, m, t) = map(int, input().split())
		(y, x) = divmod(t - 1, n)
		print(x * m + y + 1)
main()


inn = lambda : int(input())
inm = lambda : map(int, input().split())
ins = lambda : str(input())
ina = lambda : list(map(int, input().split()))

def solve():
	(n, m, x) = inm()
	x -= 1
	c = x // n
	r = x % n
	print(m * r + c + 1)

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


def solve(n, m, val):
	x = val // n + 1
	y = val % n
	if y == 0:
		return (n - 1) * m + x - 1
	return (y - 1) * m + x
res = []
count = int(input())
for i in range(count):
	(n, m, val) = map(int, input().split())
	res.append(solve(n, m, val))
for i in res:
	print(i)


n = int(input())
import math
for i in range(n):
	(n, m, x) = [int(x) for x in input().split()]
	if x % n == 0:
		(a, b) = (n, math.ceil(x / n))
	else:
		(a, b) = (x % n, math.ceil(x / n))
	if b == m:
		print(a * m)
	else:
		print((a - 1) * m + b)


import math
t = int(input())
for i in range(t):
	(N, M, X) = map(int, input().split())
	A = (X - 1) // N
	B = (X - 1) % N
	S = B * M + (A + 1)
	print(int(S))


T = int(input())
inps = []
for i in range(T):
	s = input()
	inps.append(s)
for vals in inps:
	v = vals.split()
	n = int(v[0])
	m = int(v[1])
	x = int(v[2])
	x = x - 1
	j = x // n
	i = x - n * j
	y = m * i + j + 1
	print(y)


import sys
from collections import defaultdict, Counter as CC
from math import sqrt, ceil, floor, log2
INF = float('inf')
MOD = 10 ** 9 + 7
read = lambda : [int(s) for s in sys.stdin.readline().split()]

def solve():
	(n, m, x) = read()
	i = x % n
	if i == 0:
		i += n
	j = (x - i) // n + 1
	newx = (i - 1) * m + j
	print(newx)
_ = 1
_ = int(input())
while _:
	solve()
	_ -= 1


import math
t = int(input())
for _ in range(t):
	(n1, m1, x1) = map(int, input().split())
	if x1 == 1 or x1 == n1 * m1:
		print(x1)
	else:
		r = (x1 - 1) % n1
		c = math.ceil(x1 / n1)
		print(m1 * r + c)


def fun():
	global ls
	nmx = str(input())
	nmxs = nmx.split(' ')
	n = int(nmxs[0])
	m = int(nmxs[1])
	x = int(nmxs[2])
	col = int(x / n) + 1
	row = x % n
	if row == 0:
		row = n
		col = col - 1
	num = (row - 1) * m + col
	ls.append(num)
ls = []
a = int(input())
for i in range(a):
	fun()
for i in range(a):
	print(ls[i])


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, m, x) = map(int, input().split())
	(col, row) = divmod(x - 1, n)
	print(m * row + col + 1)


t = int(input())
while t > 0:
	(n, m, x) = map(int, input().split())
	print(int(x // n + m * (n - 1)) if x % n == 0 else int(x // n + 1 + m * (x % n - 1)))
	t = t - 1


from sys import stdin

def A():
	t = int(stdin.readline())
	while t:
		t -= 1
		a = [int(x) for x in stdin.readline().split()]
		(n, m, x) = (a[0], a[1], a[2])
		l = 1
		cnt = x // n
		if cnt * n < x:
			l = cnt * n + 1
			cnt += 1
		else:
			l = cnt * n - n + 1
		cnt1 = x - l + 1
		res = cnt + (cnt1 - 1) * m
		print(res)
A()


ans = []
for _ in range(int(input())):
	(n, m, x) = map(int, input().split())
	r = (x - 1) % n + 1
	c = -(-x // n)
	ans.append(str((r - 1) * m + c))
print('\n'.join(ans))


def num_row(n, m, x):
	r = x % n
	if r == 0:
		return n
	else:
		return r

def num_col(n, m, x):
	r = x % n
	if r == 0:
		return x // n
	else:
		return x // n + 1

def check(n, m, x):
	v = 0
	row = num_row(n, m, x)
	col = num_col(n, m, x)
	v += (row - 1) * m
	v += col
	return v
listf = []
t = int(input())
for y in range(t):
	i = input().split()
	n = int(i[0])
	m = int(i[1])
	x = int(i[2])
	listf.append(check(n, m, x))
for g in listf:
	print(g)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(n, m, x) = map(int, input().split())
		(i, j) = ((x - 1) // n, (x - 1) % n)
		ans = i + j * m + 1
		print(ans)
main()


import math
import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
for i in range(inp()):
	(n, m, k) = invr()
	(a, b) = ((k - 1) // n, (k - 1) % n + 1)
	print((b - 1) * m + a + 1)