You might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy.

Lara is going to explore yet another dangerous dungeon. Game designers decided to use good old 2D environment. The dungeon can be represented as a rectangle matrix of n rows and m columns. Cell (x, y) is the cell in the x-th row in the y-th column. Lara can move between the neighbouring by side cells in all four directions.

Moreover, she has even chosen the path for herself to avoid all the traps. She enters the dungeon in cell (1, 1), that is top left corner of the matrix. Then she goes down all the way to cell (n, 1) — the bottom left corner. Then she starts moving in the snake fashion — all the way to the right, one cell up, then to the left to the cell in 2-nd column, one cell up. She moves until she runs out of non-visited cells. n and m given are such that she always end up in cell (1, 2).

Lara has already moved to a neighbouring cell k times. Can you determine her current position?


-----Input-----

The only line contains three integers n, m and k (2 ≤ n, m ≤ 10^9, n is always even, 0 ≤ k < n·m). Note that k doesn't fit into 32-bit integer type!


-----Output-----

Print the cell (the row and the column where the cell is situated) where Lara ends up after she moves k times.


-----Examples-----
Input
4 3 0

Output
1 1

Input
4 3 11

Output
1 2

Input
4 3 7

Output
3 2



-----Note-----

Here is her path on matrix 4 by 3: [Image]

Difficulty: EASY
Tags: Mathematics

Implementation

Starter code:

Solutions:
(n, m, k) = map(int, input().split())
now = [1, 1]
if k <= n - 1:
	now[0] += k
else:
	now = [n, 2]
	k -= n
	loop = k // (2 * (m - 1))
	now = [n - 2 * loop, 2]
	k %= 2 * (m - 1)
	if k <= m - 2:
		now[1] += k
	elif k <= m - 1:
		now[0] -= 1
		now[1] = m
	else:
		now[0] -= 1
		now[1] = m - (k - m + 1)
print(' '.join([str(x) for x in now]))


(n, m, k) = input().split()
(n, m, k) = (int(n), int(m), int(k))
if k <= n - 1:
	ans = (k + 1, 1)
elif m == 2:
	k -= n
	ans = (n - k, 2)
else:
	k -= n
	row = n - k // (m - 1)
	col = k % (m - 1)
	if row % 2 == 1:
		col = m - 2 - col
	ans = (row, 2 + col)
print(' '.join(map(str, ans)))


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


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
else:
	k -= n
	floor = n - k // (m - 1)
	if floor % 2:
		print(floor, m - k % (m - 1))
	else:
		print(floor, k % (m - 1) + 2)


(n, m, k) = map(int, input().split())
if k < n:
	print(str(k + 1) + ' 1')
else:
	k -= n
	y = n - k // (m - 1)
	delta = k % (m - 1)
	if y % 2 == 0:
		x = 2 + delta
	else:
		x = m - delta
	(x, y) = (y, x)
	print(str(x) + ' ' + str(y))


(n, m, k) = list(map(int, input().split()))
if k < n:
	row = k + 1
	col = 1
else:
	steps = k - (n - 1)
	row = n - (steps - 1) // (m - 1)
	col = 0
	if (steps - 1) // (m - 1) % 2 == 0:
		col = 1 + 1 + (steps - 1) % (m - 1)
	else:
		col = 1 + m - 1 - (steps - 1) % (m - 1)
print('{} {}'.format(row, col))


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
elif (k - n) // (m - 1) % 2 == 0:
	print(n - (k - n) // (m - 1), (k - n) % (m - 1) + 2)
else:
	print(n - (k - n) // (m - 1), m - (k - n) % (m - 1))


(n, m, k) = [int(x) for x in input().split()]

def solution(n, m, k):
	if 0 <= k < n:
		print('{} 1'.format(k + 1))
		return
	row = n - (k - n) // (m - 1)
	if row % 2:
		col = m - (k - n) % (m - 1)
	else:
		col = 2 + (k - n) % (m - 1)
	print('{} {}'.format(row, col))
solution(n, m, k)


(n, m, k) = map(int, input().split(' '))
if k < n:
	print(k + 1, 1)
else:
	step = k - n
	row = step // (m - 1) + 1
	col = step % (m - 1)
	reverse = (row % 2 + 1) % 2
	if reverse:
		col = m - 1 - col - 1
	print(n - row + 1, 2 + col)


(n, m, a) = map(int, input().split())
if a < n:
	print(a + 1, 1)
elif a == n:
	print(n, 2)
else:
	(sa, so) = (-1, -1)
	a = a - n
	mm = m - 1
	tm = a // mm
	tb = a % mm
	sa = n - tm
	if tm % 2 == 0:
		so = 2 + tb
	else:
		so = m - tb
	if so < 1:
		(sa, so) = (1, 2)
	print(sa, so)


import sys, math, queue
MOD = 998244353
sys.setrecursionlimit(1000000)
(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
	exit()
k -= n
x = k // (m - 1)
y = k % (m - 1)
if x % 2 == 1:
	print(n - x, m - y)
else:
	print(n - x, y + 2)


while True:
	try:
		import math
		(n, m, k) = map(int, input().split())
		if k < n:
			print(k + 1, '1')
		else:
			t = abs(n - k)
			t1 = m - 1
			t2 = t // t1
			if t2 % 2 == 0:
				t3 = t2 * t1 + n
				t4 = abs(t3 - k) + 2
				print(n - t2, t4)
			else:
				t3 = t2 * t1 + n
				t4 = abs(t3 - k)
				t4 = m - t4
				print(n - t2, t4)
	except EOFError:
		break


import math
(n, m, k) = map(int, input().strip().split(' '))
if k < n:
	print(k + 1, 1, end=' ')
elif m == 1000000000 and n == 1000000000 and (k == 1999999998):
	print('1000000000 1000000000')
else:
	pp = 0
	p1 = 0
	p2 = 0
	p1 = math.ceil((m * n - k) / (m - 1))
	a = m * n - (m - 1)
	pp = a - (p1 - 1) * (m - 1)
	if p1 % 2 == 0:
		p2 = 2 + (k - pp)
	else:
		p2 = m - (k - pp)
	print(p1, p2, end=' ')


(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
(x, y) = (0, 0)
if k <= n - 1:
	(x, y) = (k + 1, 1)
else:
	h = (k - n) // (m - 1)
	w = (k - n) % (m - 1)
	if h % 2 == 0:
		(x, y) = (n - h, 2 + w)
	else:
		(x, y) = (n - h, m - w)
print('{} {}'.format(x, y))


def inpmap():
	return list(map(int, input().split()))
(n, m, k) = inpmap()
if k < n:
	print(k + 1, 1)
else:
	k -= n
	(a, b) = divmod(k, m - 1)
	print(n - a, m - b if a % 2 else b + 2)


(n, m, k) = map(int, input().split())
if k < n:
	print('%d 1' % (k + 1))
else:
	k -= n
	co = n - k // (m - 1)
	if k // (m - 1) & 1:
		li = m - k % (m - 1)
	else:
		li = k % (m - 1) + 2
	print(co, li)


(n, m, k) = list(map(int, input().split()))
if k < n:
	print(k + 1, 1)
else:
	k -= n
	m -= 1
	mo = k % (2 * m)
	if mo >= m:
		mo = 2 * m - 1 - mo
	print(n - k // m, 2 + mo)


(n, m, k) = map(int, input().split())
if k == 0:
	out = '1 1'
elif k <= n - 1:
	out = str(1 + k) + ' ' + '1'
elif k >= n * m:
	out = '1 2'
else:
	k -= n
	y = n - k // (m - 1)
	if y % 2 == 0 or y == 0:
		x = 3 + (k - 1 - (n - y) * (m - 1))
	else:
		x = m - (k - 1 - (n - y) * (m - 1)) - 1
	out = str(y) + ' ' + str(x)
print(out)


[n, m, k] = map(int, input().strip().split())

def solve(n, m, k):
	if k < n:
		return (k + 1, 1)
	else:
		k -= n
		d = k // (2 * (m - 1))
		r = k % (2 * (m - 1))
		x = n - 2 * d
		if r < m - 1:
			y = 2 + r
		else:
			y = m + m - 1 - r
			x -= 1
	return (x, y)
(x, y) = solve(n, m, k)
print(x, y)


(n, m, k) = (int(x) for x in input().split())
if k < n:
	print(k + 1, 1)
else:
	row = n - 1 - (k - n) // (m - 1)
	col = (k - n) % (m - 1)
	if row % 2 == 1:
		print(row + 1, col + 2)
	else:
		print(row + 1, m - col)


from __future__ import division, print_function
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
from fractions import Fraction

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

def si():
	return str(input())

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

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

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

def fsi():
	return str(stdin.readline())

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

def fli():
	return list(fmi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

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

def ntl(n):
	return [int(i) for i in str(n)]

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

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)
(n, m, k) = mi()
if k < n:
	print(k + 1, 1)
	exit()
elif k == n:
	print(k, 2)
	exit()
else:
	k = k - n
	m -= 1
	x = k // m
	y = k % m
	if x % 2 == 0:
		print(n - x, y + 2)
	else:
		m += 1
		print(n - x, m - y)


def main():
	(n, m, k) = map(int, input().split())
	if k < n:
		(y, x) = (n - k - 1, 1)
	else:
		(y, x) = divmod(k - n, m * 2 - 2)
		y *= 2
		if x < m - 1:
			x += 2
		else:
			x = m * 2 - x - 1
			y += 1
	print(n - y, x)
main()


(n, m, k) = map(int, input().split())
if k < n:
	(i, j) = (k + 1, 1)
else:
	k -= n
	l = m - 1
	i = n - k // l
	k %= l
	j = m - k if i & 1 else k + 2
print(i, j)


def solve():
	(n, m, k) = map(int, input().split())
	if k <= n - 1:
		print(k + 1, 1)
		return
	k -= n
	mov_right = True if k % (2 * (m - 1)) < m - 1 else False
	row = n - k // (m - 1)
	if mov_right:
		col = 2 + k % (2 * (m - 1))
	else:
		col = 1 + m - 1 - (k % (2 * (m - 1)) - (m - 1))
	print(row, col)
solve()


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, '1')
elif k == n:
	print(n, '2')
else:
	k = k - n
	m_d = k // (m - 1)
	m_m = k % (m - 1)
	if m_d % 2 == 1:
		m_m = m - m_m
	else:
		m_m += 2
	m_d = n - m_d
	print(m_d, m_m)


(n, m, k) = map(int, input().split())
if k <= n - 1:
	print(1 + k, 1)
elif k <= n + m - 2:
	print(n, 1 + k - (n - 1))
else:
	k -= n + m - 2
	m -= 1
	(a, b) = (k // m, k % m)
	if a % 2 == 0:
		if b > 0:
			a += 1
			b -= 1
		sty = m + 1
		print(n - a, sty - b)
	else:
		if b > 0:
			a += 1
			b -= 1
		sty = 2
		print(n - a, sty + b)


(n, m, k) = list(map(int, input().split()))
if k < n:
	print(str(k + 1) + ' 1')
else:
	(div, mod) = divmod(k - n, m - 1)
	if div % 2:
		print(str(n - div) + ' ' + str(m - mod))
	else:
		print(str(n - div) + ' ' + str(2 + mod))


def main():
	(n, m, k) = list(map(int, input().split()))
	if k < n:
		x = k + 1
		y = 1
	else:
		k -= n
		x = n - k // (m - 1)
		if x % 2 == 0:
			y = 2 + k % (m - 1)
		else:
			y = m - k % (m - 1)
	print(x, int(y))
main()


rad = lambda : map(int, input().split())
(n, m, k) = rad()
if k <= n - 1:
	print(1 + k, 1)
else:
	kp = k - n
	moveups = kp // (m - 1)
	reste = kp - moveups * (m - 1)
	ansligne = n - moveups
	if ansligne % 2 == 0:
		anscol = 2 + reste
	else:
		anscol = m - reste
	print(ansligne, anscol)


import json

def read_ints():
	return [int(x) for x in input().split()]

def solve(n_rows, n_cols, k):
	if k < n_rows:
		return (k + 1, 1)
	else:
		k -= n_rows - 1
		n_up = (k - 1) // (n_cols - 1)
		x = n_rows - n_up
		if n_up % 2 == 0:
			y = 1 + k % (n_cols - 1)
			if y == 1:
				y = n_cols
		else:
			y = n_cols - (k - 1) % (n_cols - 1)
		return (x, y)

def main():
	(n_rows, n_cols, k) = read_ints()
	(x, y) = solve(n_rows, n_cols, k)
	print(x, y)
main()


(n, m, k) = map(int, input().split())
(d, r) = divmod(k - n, m - 1)
if k < n:
	print(1 + k, 1)
else:
	print(n - d, m - r if d % 2 else 2 + r)


(n, m, k) = map(int, input().split())
if k <= n - 1:
	print(1 + k, 1)
	exit(0)
k = k - (n - 1)
one_row_steps = m - 1
rows = (k - 1) // one_row_steps
cols = (k - 1) % one_row_steps
if rows % 2 == 0:
	cols = 2 + cols
else:
	cols = m - cols
print(n - rows, cols)


import math
(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
else:
	k -= n - 1
	inv_y = k // (m - 1)
	k = k % (m - 1)
	if k != 0:
		inv_y += 1
	if inv_y % 2 == 0:
		y = 2
		if k != 0:
			y = m - k + 1
		print(n - inv_y + 1, y)
		pass
	else:
		y = m
		if k != 0:
			y = 1 + k
		print(n - inv_y + 1, y)
		pass


import math
(n, m, k) = map(int, input().split())

def get_x(l, m):
	s = l // (m - 1)
	if l % (m - 1) == 0:
		return s
	else:
		return s + 1
if k < n:
	print(1 + k, 1)
elif k < n + m - 2:
	print(n, 1 + k - (n - 1))
else:
	l = k - (n + m - 2)
	x = get_x(l, m)
	r = (l - 1) % (m - 1) + 1
	if x % 2 == 0:
		print(n - x, 1 + r)
	else:
		print(n - x, m - r + 1)


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
else:
	k -= n
	if m == 2:
		print(n - k, 2)
	else:
		d = k // (2 * (m - 1))
		x = n
		y = 2
		x -= 2 * d
		k -= d * (2 * (m - 1))
		if k < m - 1:
			y += k
		else:
			k -= m - 1
			y = m - k
			x -= 1
		print(x, y)


(n, m, k) = list(map(int, input().strip().split()))
if k < n:
	print(str(k + 1) + ' 1')
else:
	rem = k - n
	cols = rem % (m - 1)
	rows = rem // (m - 1)
	if rows % 2 == 1:
		print(str(n - rows) + ' ' + str(m - cols))
	else:
		print(str(n - rows) + ' ' + str(cols + 2))


(n, m, k) = [int(x) for x in input().split()]
if k < n:
	print(k + 1, 1)
else:
	k = k - n + 1
	val = m - 1
	a = k // val
	b = k % val
	x = n - a + 1
	y = -1
	if b != 0:
		x -= 1
	if b == 0:
		if a % 2 == 1:
			y = m
		else:
			y = 2
	elif a % 2 == 1:
		y = m + 1 - b
	else:
		y = 1 + b
	print(x, y)


(n, m, k) = map(int, input().split(' '))
(x, y) = (1, 1)
if k < n:
	x += k
else:
	k -= n - 1
	br_redova = k // (m - 1)
	if br_redova == 0:
		y += k
		x = n
	else:
		k -= br_redova * (m - 1)
		x = n - (br_redova - 1)
		y = 2 if br_redova % 2 == 0 else m
		smer = 1 if br_redova % 2 == 0 else -1
		if k > 0:
			x -= 1
			k -= 1
			y += smer * k
print('{} {}'.format(x, y))


(n, m, k) = map(int, input().split())
if k < n:
	print(1 + k, 1)
else:
	k -= n
	k1 = k // (m - 1)
	k2 = k % (m - 1)
	if k1 % 2 == 0:
		print(n - k1, k % (m - 1) + 2)
	else:
		print(n - k1, m - k % (m - 1))


(H, W, K) = list(map(int, input().split()))
if K < H:
	print(K + 1, 1)
	return
K -= H
W -= 1
(d, m) = divmod(K, W * 2)
if m < W:
	print(H - 2 * d, 2 + m)
else:
	m -= W
	print(H - 1 - 2 * d, W - m + 1)


a = input().split()
if int(a[2]) < int(a[0]):
	print(str(int(a[2]) + 1) + ' 1')
else:
	lr = int(a[0])
	lc = int(a[1])
	lk = int(a[2]) - lr
	lz = lk // (lc - 1)
	x = lr - lz
	lpk = lk % (lc - 1)
	if lz % 2 == 0:
		y = 2 + lpk
	else:
		y = lc - lpk
	print(str(x) + ' ' + str(y))


[N, M, K] = input().split(' ')
N = eval(N)
M = eval(M)
K = eval(K)
if K < N:
	print(str(K + 1) + ' 1')
else:
	K -= N
	DX = K // (M - 1)
	DY = K % (M + M - 2)
	if DY >= M - 1:
		DY = 2 * M - 2 - DY - 1
	print(str(N - DX) + ' ' + str(DY + 2))


(n, m, k) = list(map(int, input().split()))
if k < n:
	print(k + 1, 1)
else:
	k = k - (n - 1)
	tmp = k // (2 * (m - 1))
	k = k % (2 * (m - 1))
	(x, y) = (n - 2 * tmp + 1, 2)
	if k > 0:
		x = x - 1
		k = k - 1
		if k <= m - 2:
			y = y + k
		else:
			k = k - (m - 1)
			x = x - 1
			y = m - k
	print(x, y)


EPS = 1e-09

def main():
	(n, m, k) = [int(x) for x in input().split()]
	nn = n - 1
	mm = m - 1
	if k <= nn:
		print(k + 1, 1)
		return
	if k <= nn + mm:
		print(n, k - nn + 1)
		return
	k -= nn + mm
	step = mm
	row = nn - (k + step - 1) // step
	if row % 2 == 0:
		if k % step == 0:
			col = 2
		else:
			col = step - k % step + 2
	elif k % step == 0:
		col = m
	else:
		col = m - step + k % step
	print(row + 1, col)
main()


import sys
(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
	sys.exit()
k -= n
x = n - k // (m - 1)
if x % 2 == 0:
	y = k % (m - 1) + 2
else:
	y = m - k % (m - 1)
print(x, y)


(n, m, k) = list(map(int, input().split()))
if k <= n - 1:
	print(f'{1 + k} 1')
else:
	l = k - (n - 1)
	b = (l - 1) // (m - 1)
	c = (l - 1) % (m - 1) + 1
	row = n - b
	col = None
	if b % 2 == 0:
		col = 1 + c
	else:
		col = m + 1 - c
	print(f'{row} {col}')


li = input().split(' ')
n = int(li[0])
m = int(li[1])
k = int(li[2])
if k < n:
	print(k + 1, 1)
	exit()
elif k >= n and k <= n + m - 2:
	print(n, k - n + 2)
else:
	p = m * n - k
	row = (p - 1) // (m - 1) + 1
	if row % 2 == 0:
		column = m - 2 - (p - 1) % (m - 1) + 2
	else:
		column = (p - 1) % (m - 1) + 2
	print(row, column)


def main():
	(n, m, k) = [int(i) for i in input().split(' ')]
	if k < n:
		print(k + 1, 1)
	else:
		k -= n
		m -= 1
		h1 = k // (2 * m) * 2
		h2 = k % (2 * m)
		if h2 < m:
			print(n - h1, 2 + h2)
		else:
			print(n - h1 - 1, 1 + m - h2 % m)
main()


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
if k < n:
	x = k + 1
	y = 1
else:
	k -= n - 1
	m -= 1
	a = (k - 1) // m
	x = n - a
	b = k % m
	if b == 0:
		b += m
	c = a % 2
	if c == 0:
		y = b + 1
	else:
		y = m - b + 2
print(x, y)


a = input().split()
n = int(a[0])
m = int(a[1])
k = int(a[2])
k += 1
if k <= n:
	print(k, 1)
else:
	k = k - n
	if k % (m - 1) == 0:
		vert = k // (m - 1)
	else:
		vert = k // (m - 1) + 1
	vert = n - vert + 1
	if vert % 2 == 0:
		hor = (k - 1) % (m - 1) + 1
	else:
		hor = m - (k - 1) % (m - 1) - 1
	print(vert, hor + 1)


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
(n, m, k) = rint()
if k < n:
	print(k + 1, 1)
	exit()
moc = (k - n) // (m - 1)
res = (k - n) % (m - 1)
row = n - moc
if row % 2 == 0:
	col = 2 + res
else:
	col = m - res
print(row, col)


from decimal import *

def main():
	(n, m, k) = list(map(int, input().split()))
	getcontext().prec = 18
	if k < n:
		x = k + 1
		y = 1
	else:
		k -= n
		x = n - k // (m - 1)
		if x % 2 == 0:
			y = 2 + k % (m - 1)
		else:
			y = m - k % (m - 1)
	print(x, int(y))
main()


(n, m, k) = [int(x) for x in input().split()]
if k == 0:
	print(1, 1)
	exit()
if k == n * m - 1:
	print(1, 2)
	exit()
if k < n:
	print(k + 1, 1)
	exit()
if k >= n and k <= n + m - 2:
	print(n, k - n + 2)
	exit()
k -= n + m - 2
q = k // (m - 1)
rem = k % (m - 1)
if rem == 0:
	row = n - q
	if row & 1:
		col = 2
	else:
		col = m
	print(row, col)
	exit()
row = n - 1 - q
if row & 1:
	col = m - rem + 1
	print(row, col)
else:
	col = rem + 1
	print(row, col)


(n, m, k) = [int(t) for t in str.split(input())]
axis0 = 0
if k < n:
	axis0 = k + 1
	axis1 = 1
else:
	new_k = k - n
	axis0 = n - new_k // (m - 1)
	axis1 = 2 + max(min(new_k % (2 * m - 2), 2 * m - 3 - new_k % (2 * m - 2)), 0)
print(axis0, axis1)


(n, m, k) = map(int, input().split())
ans = (0, 0)
if k < n:
	ans = (k + 1, 1)
else:
	k -= n
	r = n - k // (m - 1)
	if r % 2:
		c = m - k % (m - 1)
	else:
		c = 2 + k % (m - 1)
	ans = (r, c)
print(*ans)


import math
(n, m, k) = map(int, input().split())
if k >= n:
	y = (k - n + 1) // (m - 1)
	if (k - n + 1) % (m - 1) == 0:
		y -= 1
	y = n - y
	x = (k - n + 1) % (m - 1)
	if x == 0:
		x = m - 1
	if y % 2 != 0:
		x = m - x
	x += 1
	print(y, x)
else:
	print(k + 1, 1)


(n, m, k) = map(int, input().split())
current = n * m - 1
if k < n:
	print(k + 1, 1)
else:
	remaining = k - n
	row_from_down = remaining // (m - 1)
	row = n - row_from_down
	if row % 2:
		col = remaining % (m - 1)
		col = m - col
	else:
		col = remaining % (m - 1)
		col += 2
	print(row, col)


(n, m, k) = map(int, input().split())
if k < n:
	print('%d %d' % (k + 1, 1))
else:
	row = n - (k - n) // (m - 1)
	if row & 1:
		print('%d %d' % (row, m - (k - n) % (m - 1)))
	else:
		print('%d %d' % (row, (k - n) % (m - 1) + 2))


(n, m, k) = map(int, input().split())
if k <= n - 1:
	print(1 + k, 1)
else:
	c = k - (n - 1)
	x = n - (c - 1) // (m - 1)
	y = (c - 1) % (m - 1) + 1
	if x % 2 == 0:
		y = 1 + y
	else:
		y = m - (y - 1)
	print(x, y)


(n, m, t3) = map(int, input().split())
if t3 < n:
	print(1 + t3, ' ', 1, sep='')
else:
	t3 -= n
	if m >= 2:
		x = t3 // (m - 1)
		if x % 2 == 0:
			a = t3 % (m - 1) + 2
			b = n - x
		else:
			a = m - t3 % (m - 1)
			b = n - x
		print(b, a)


(a, b, c) = map(int, input().split())
if c < a:
	print(1 + c, 1)
else:
	c -= a
	r = c // (b - 1)
	k = c - r * (b - 1)
	if r % 2 == 0:
		print(a - r, 2 + k)
	else:
		print(a - r, b - k)


(n, m, k) = map(int, input().split())
X = 0
Y = 0
if k < n:
	X = k + 1
	Y = 1
elif k >= n and k <= m + n - 2:
	X = n
	Y = k - n + 2
else:
	k -= n + m - 1
	temp = k // (m - 1)
	X = n - 1 - temp
	isEven = X % 2 == 0
	remains = k % (m - 1)
	if not isEven:
		Y = m - remains
	else:
		Y = remains + 2
print(X, Y)


(n, m, k) = list(map(int, input().split()))
if k < n:
	print(k + 1, 1)
	exit(0)
k = k + 1 - n
p = k // (m - 1) - 1 * (k % (m - 1) == 0)
q = k % (m - 1) if k % (m - 1) else m - 1
x = q + 1 if p % 2 == 0 else m - q + 1
y = n - p
print(y, x)


(n, m, k) = list(map(int, input().split()))
if k < n:
	print(1 + k, 1)
else:
	k -= n
	a = k % (2 * (m - 1))
	b = k // (2 * (m - 1))
	if a < m - 1:
		print(n - 2 * b, 2 + a)
	else:
		a -= m - 1
		print(n - 2 * b - 1, m - a)


import math
(n, m, k) = list(map(int, input().split()))
if k <= n - 1:
	print(k + 1, 1)
else:
	z = k - (n - 1)
	row = 0
	if z % (m - 1) == 0:
		row = z // (m - 1)
	else:
		row = z // (m - 1) + 1
	i = n - row + 1
	e = row * (m - 1)
	if row % 2 == 0:
		j = e - (k - (n - 1)) + 2
	else:
		j = e - (k - (n - 1))
		j = m - j
	print(i, j)


(n, m, k) = map(int, input().split())
(col, row) = (0, 0)
if k <= n - 1:
	print(k + 1, 1)
else:
	r = (k - n + 1 + m - 2) // (m - 1)
	row = n + 1 - r
	c = (k - n + 1) % (m - 1)
	if r % 2 != 0:
		if c != 0:
			col = c + 1
		else:
			col = m
	elif c != 0:
		col = m + 1 - c
	else:
		col = 2
	print(row, col)


import os
import sys
import math

def solve(x, y, k):
	row = 1
	column = 1
	if k < x:
		row += k
	else:
		row = x - (k - x) // (y - 1)
		column = (k - x) % (y - 1)
		if row % 2 == 1:
			column = y - column
		else:
			column += 2
	return str(row) + ' ' + str(column)
xyk = input().split()
print(solve(int(xyk[0]), int(xyk[1]), int(xyk[2])))


(n, m, k) = input().split()
import math
n = int(n)
m = int(m)
k = int(k)
if k + 1 <= n:
	print(k + 1, 1)
else:
	n0 = n
	n = n - (k - n) // (m - 1)
	if n % 2 == 0:
		if (k - n0 + 1) % (m - 1) == 0:
			m = m
		else:
			m = (k - n0 + 1) % (m - 1) + 1
	elif (k - n0 + 1) % (m - 1) == 0:
		m = 2
	else:
		m = m + 1 - (k - n0 + 1) % (m - 1)
	print(n, m)


(n, m, k) = map(int, input().split())
if k <= n - 1:
	print('{} {}'.format(k + 1, 1))
else:
	q = (k - n) // (m - 1)
	r = k - (n - 1) - q * (m - 1)
	if q % 2 == 0:
		print('{} {}'.format(n - q, r + 1))
	else:
		print('{} {}'.format(n - q, m - r + 1))


def problemb():
	return 'yezzi mel tzaabin nchalah zina'
(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, ' ', 1, sep='')
else:
	k -= n
	if m >= 2:
		x = k // (m - 1)
		if x % 2 == 0:
			a = k % (m - 1) + 2
			b = n - x
		else:
			a = m - k % (m - 1)
			b = n - x
		print(b, a)


(N, M, K) = map(int, input().split())
if K <= N - 1:
	print(K + 1, 1)
else:
	res = K - (N - 1)
	if (res - 1) // (M - 1) % 2 == 0:
		y = N - (res - 1) // (M - 1)
		if res % (M - 1) == 0:
			x = M
		else:
			x = 1 + res % (M - 1)
		print(y, x)
	else:
		y = N - (res - 1) // (M - 1)
		x = M - (res - 1) % (M - 1)
		print(y, x)


(n, m, k) = map(int, input().split())
if k < n:
	print('{} 1'.format(k + 1))
else:
	k -= n - 1
	m -= 1
	row_at = (k - 1) // m
	col_at = (k - 1) % m
	col_at = col_at + 2 if row_at % 2 == 0 else m - col_at + 1
	row_at = n - row_at
	print('{} {}'.format(row_at, col_at))


(n, m, k) = map(int, input().split(' '))

def printResult(x, y):
	print(str(x) + ' ' + str(y))

def solve(n, m, k):
	if k < n:
		printResult(1 + k, 1)
	else:
		(upX, rest) = divmod(k - n, m - 1)
		if upX % 2 == 0:
			leftY = rest
		else:
			leftY = m - 2 - rest
		printResult(n - upX, 2 + leftY)
solve(n, m, k)


(n, m, k) = (int(e) for e in input().split(' '))
if k < n:
	print(str(k + 1) + ' ' + '1')
	exit()
k -= n
k += 1
if k == 1:
	print(str(n) + ' 2')
	exit()
rez = k // (m - 1)
rem = k % (m - 1)
if rem == 0:
	if rez % 2 == 0:
		if rez == 0:
			rez = 1
		print(str(n - rez + 1) + ' 2')
	else:
		print(str(n - rez + 1) + ' ' + str(m))
elif rez % 2 == 0:
	print(str(n - rez) + ' ' + str(1 + rem))
else:
	print(str(n - rez) + ' ' + str(m - rem + 1))


(n, m, k) = list(map(int, input().split()))
if k <= n - 1:
	print(1 + k, 1)
else:
	k -= n
	d = k // (m - 1)
	k %= m - 1
	if d % 2 == 0:
		print(n - d, k + 2)
	else:
		print(n - d, m - k)


(n, m, k) = list(map(int, input().split()))
if k < n:
	print(1 + k, 1)
else:
	k -= n
	k2 = k // (m - 1)
	k3 = k % (m - 1)
	if k2 % 2 == 0:
		print(n - k2, k % (m - 1) + 2)
	else:
		print(n - k2, m - k % (m - 1))


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
else:
	k -= n
	l = k // (m - 1)
	md = k % (m - 1)
	a = n - l
	if a % 2:
		if md == 0:
			b = m
		else:
			b = m - md
	elif md == 0:
		b = 2
	else:
		b = 2 + md
	print(a, b)


(n, m, k) = [int(i) for i in input().split(' ')]
(ans_x, ans_y) = (0, 0)
if k < n:
	(ans_x, ans_y) = (k + 1, 1)
else:
	res = k - n
	line = res // (m - 1)
	raw = res - line * (m - 1) + 2
	ans_x = n - line
	if line % 2 == 0:
		ans_y = raw
	else:
		ans_y = m + 2 - raw
print('{} {}'.format(ans_x, ans_y))


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
else:
	k = k - n
	t1 = k // (m - 1)
	t2 = k % (m - 1)
	if t1 % 2:
		print(n - t1, m - t2)
	else:
		print(n - t1, 2 + t2)


(n, m, k) = map(int, input().split())
if n == k:
	print(n, 2)
	quit()
if n > k:
	print(k + 1, 1)
	quit()
k = k - n
x = n - k // (m - 1)
if x % 2 == 0:
	print(x, 2 + k % (m - 1))
else:
	print(x, m - k % (m - 1))


import logging
fmt = '%(levelname)s - %(name)s (line:%(lineno)s) - %(message)s'
formatter = logging.Formatter(fmt)
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
ch.setFormatter(formatter)
logger = logging.getLogger('lara_croft_and_the_new_game')
logger.setLevel(logging.ERROR)
logger.addHandler(ch)

def solve(n, m, k):
	if k < n:
		return (k + 1, 1)
	k -= n
	row = n - k // (m - 1)
	_col = k % (m - 1)
	if row % 2 == 0:
		col = 2 + _col
	else:
		col = m - _col
	return (row, col)

def main():
	(n, m, k) = map(int, input().strip().split())
	result = solve(n, m, k)
	print(' '.join(map(str, result)))
main()


(n, m, k) = map(int, input().split())
(r, c) = (None, None)
if k < n:
	(r, c) = (k + 1, 1)
else:
	k -= n
	(a, b) = (k // (m - 1), k % (m - 1))
	r = n - a
	if a % 2 == 0:
		c = b + 2
	else:
		c = m - b
print(r, c)


[n, m, k] = [int(i) for i in input().split(' ')]
if n == 1 and m == 1 and (k == 1):
	print(str(1) + ' ' + str(1))
elif k <= n - 1:
	print(str(k + 1) + ' ' + str(1))
else:
	k = k - (n - 1)
	q = k // (m - 1)
	r = k % (m - 1)
	if q % 2 == 0:
		if r == 0:
			print(str(n - q + 1) + ' ' + str(2))
		else:
			print(str(n - q) + ' ' + str(2 + r - 1))
	elif r == 0:
		print(str(n - q + 1) + ' ' + str(m))
	else:
		print(str(n - q) + ' ' + str(m - r + 1))


(n, m, k) = map(int, input().split())

def findCell(n, m, k):
	if k <= n - 1:
		return [k + 1, 1]
	else:
		width = m - 1
		remaining = k - (n - 1)
		area = 2 * width
		level = remaining // area
		positionInABlock = remaining % area
		if positionInABlock == 0:
			return [n - 1 - (level - 1) * 2, 2]
		elif positionInABlock > m - 1:
			2 * m - positionInABlock
			return [n - 1 - level * 2, 2 * m - positionInABlock]
		else:
			return [n - level * 2, 1 + positionInABlock]
print(*findCell(n, m, k))


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
elif k <= m + n - 2:
	print(n, k - n + 2)
elif n == 1 and m == 2 and (k == 3):
	print(1, 2)
elif n == 1 and m == 2 and (k == 2):
	print(2, 2)
else:
	k = k - (n + m - 1)
	(row, col) = divmod(k, m - 1)
	if row % 2 == 0:
		print(n - 1 - row, m - col)
	else:
		print(n - 1 - row, 2 + col)


import sys
(n, m, k) = map(int, input().split())
if n - 1 >= k:
	print(k + 1, 1)
else:
	(div, mod) = divmod(k - n, m - 1)
	if div % 2 == 0:
		print(n - div, mod + 2)
	else:
		print(n - div, m - mod)


from bisect import bisect_left, bisect_right

def _input():
	return map(int, input().strip().split())

def _print(s):
	print(''.join(map(str, s)))
(n, m, k) = _input()
if k < n:
	print(k + 1, 1)
	exit(0)
k -= n
(x, y) = (n, 2)
d = k // (2 * (m - 1))
r = k % (2 * (m - 1))
x -= 2 * d
if r < m - 1:
	y += r
elif r == m - 1:
	x -= 1
	y = m
else:
	x -= 1
	y = m - (r - m + 1)
print(x, y)


s = input().split()
(n, m, k) = (int(s[0]), int(s[1]), int(s[2]))
(x, y) = (0, 0)
if k < n + m - 1:
	if k <= n - 1:
		x = k + 1
		y = 1
	elif k >= n:
		x = n
		y = k - n + 2
else:
	k = k - (n + m - 2)
	m = m - 1
	if k % m == 0:
		x = k // m
	else:
		x = k // m + 1
	y = k - (x - 1) * m
	if x % 2 == 0:
		y = m - y + 1
	else:
		pass
	x = x + 1
	x = n - x + 1
	y = m - y + 2
print(x, y)


(n, m, k) = [int(i) for i in input().split()]
if k < n:
	print('%d %d' % (k + 1, 1))
elif k <= n - 1 + (m - 1):
	k -= n - 1
	print('%d %d' % (n, k + 1))
else:
	x = m
	y = n - 1
	k -= n - 1 + (m - 1) + 1
	s = (m - 1) * 2
	lift = 0
	if s == 0:
		lift = 0
	else:
		lift = k // s
	y -= lift * 2
	elev = lift * s
	if elev + (m - 2) >= k:
		x -= abs(elev - k)
	else:
		y -= 1
		elev += s - 1
		x -= abs(elev - k)
	print('%d %d' % (y, x))


def main():
	(n, m, k) = map(int, input().split())
	if k < n:
		print(k + 1, 1)
		return
	k -= n
	row = n - k // (m - 1)
	if not row & 1:
		print(row, k % (m - 1) + 2)
	else:
		print(row, m - k % (m - 1))
main()


(n, m, k) = map(int, input().split())
if k <= n - 1 + m - 1:
	if k <= n - 1:
		print(1 + k, 1)
	else:
		print(n, 1 + k - (n - 1))
else:
	k = k - n
	r = k // (m - 1)
	s = k % (m - 1)
	if r % 2 == 0:
		t = 2 + k % (m - 1)
	elif r % 2 == 1:
		t = m - k % (m - 1)
	print(n - r, t)


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
	exit(0)
if k == n:
	print(n, 2)
	exit(0)
k -= n
d = k // (m - 1)
r = k % (m - 1)
if d % 2 == 0:
	if r == m - 1:
		print(n - d - 1, r + 2)
	else:
		print(n - d, r + 2)
elif r == m - 1:
	print(n - d - 1, 2)
else:
	print(n - d, m - r)


(n, m, k) = map(int, input().split())
from math import ceil
if k < n:
	print(k + 1, 1)
	exit()
k = k - n
row = k // (m - 1)
rem = k % (m - 1)
print(n - row, end=' ')
if row % 2 == 0:
	print(2 + rem)
else:
	print(m - rem)


[n, m, k] = [int(i) for i in input().split()]
if k < n:
	print(k + 1, 1)
else:
	k -= n
	r = n - k // (m - 1)
	if r % 2 == 0:
		c = 2 + k % (m - 1)
	else:
		c = m - k % (m - 1)
	print(r, c)


(n, m, k) = map(int, input().split())
if k <= n - 1:
	print(k + 1, 1)
else:
	l = (k - n + 1) // (m - 1)
	o = (k - n + 1) % (m - 1)
	x = 0
	if o == 0:
		x = n - l + 1
	else:
		x = n - l
	y = 0
	if x % 2 == 0:
		if o == 0:
			y = m
		else:
			y = 1 + o
	elif o == 0:
		y = 2
	else:
		y = m - o + 1
	print(x, y)


import math
(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
else:
	k -= n
	sty = int((k - k % (m - 1)) / (m - 1)) + 1
	k -= (sty - 1) * (m - 1)
	sty = n - sty + 1
	if (n - sty) % 2 == 0:
		stx = 2 + k
	else:
		stx = m - k
	print(sty, stx)


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, ' 1')
	raise SystemExit()
k -= n
if k // (m - 1) % 2 == 0:
	print(n - k // (m - 1), 2 + k % (m - 1))
else:
	print(n - k // (m - 1), m - k % (m - 1))


(n, m, k) = [int(i) for i in input().split()]
if k < n:
	print(k + 1, 1)
elif k == n:
	print(k, 2)
else:
	k -= n
	i = n - k // (m - 1)
	j = k % (m - 1)
	if i % 2 == 1:
		j = m - 1 - j
	else:
		j += 1
	print(i, j + 1)


params = list(map(int, input().split()))
if params[2] < params[0]:
	row = 1 + params[2]
	col = 1
else:
	params[2] -= params[0]
	row = params[0] - params[2] // (params[1] - 1)
	nW = params[1] - 1
	params[2] %= 2 * (nW - 1) + 2
	if params[2] < nW:
		col = 2 + params[2]
	else:
		col = 1 + nW - (params[2] - nW)
print('{} {}'.format(row, col))


(n, m, k) = list(map(int, input().split()))
if k < n:
	r = [k + 1, 1]
else:
	m -= 1
	k -= n
	(y, x) = divmod(k, m)
	r = [n - y, 0]
	if y & 1:
		r[1] = m - x + 1
	else:
		r[1] = x + 2
print(*r)


(a, b, c) = map(int, input().split())
if c < a:
	print(c + 1, ' ', 1, sep='')
else:
	c -= a
	if b >= 2:
		x = c // (b - 1)
		if x % 2 == 0:
			h = c % (b - 1) + 2
			j = a - x
		else:
			h = b - c % (b - 1)
			j = a - x
		print(j, h)


import sys
import math

def main():
	(n, m, k) = map(int, input().split())
	if k <= n - 1:
		print(k + 1, 1)
		return
	m -= 1
	k -= n
	skip = k // m
	x = n - skip
	if skip % 2 == 0:
		y = 2 + k % m
	else:
		y = m + 1 - k % m
	print(x, y)
main()


(n, m, k) = [int(i) for i in input().split(' ')]
if k < n:
	print(k + 1, 1)
else:
	k = k - n
	(level, remainder) = divmod(k, m - 1)
	x = n - level
	direction = level % 2
	if direction == 0:
		y = remainder + 2
	else:
		y = m - remainder
	print(x, y)


(n, m, k) = map(int, input().split())
if k < n:
	x = k + 1
	y = 1
else:
	t = (k - n) // (m - 1)
	w = (k - n) % (m - 1)
	x = n - t
	if t % 2 == 0:
		y = 2 + w
	else:
		y = m - w
print(x, y)


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
else:
	t = k - n
	vert = t // (m - 1)
	hor = t % (m - 1)
	print(n - vert, [m - hor, hor + 2][1 - vert % 2])


import sys

def mp():
	return map(int, input().split())
(n, m, k) = mp()
if k <= n - 1:
	print(k + 1, 1)
	sys.exit()
k -= n
l = k // (m - 1)
if l % 2 == 0:
	r = k % (m - 1)
else:
	r = m - 2 - k % (m - 1)
print(n - l, r + 2)


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
else:
	k -= n
	row = n - k // (m - 1)
	if k // (m - 1) % 2 == 0:
		col = 2 + k % (m - 1)
	else:
		col = m - k % (m - 1)
	print(row, col)


(n, m, k) = map(int, input().split())

def cord(n, m, k):
	if k < n:
		return (k + 1, 1)
	elif k == n:
		return (n, 2)
	else:
		m -= 1
		k -= n
		mm = k // m
		kk = k % m
		if mm % 2 == 0:
			return (n - mm, 2 + kk)
		else:
			return (n - mm, 1 + m - kk)
a = cord(n, m, k)
print(a[0], a[1])


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

def main():
	(n, m, k) = readline()
	if k < n:
		print(k + 1, 1)
	else:
		k -= n
		(q, r) = divmod(k, m - 1)
		print(n - q, m - r if q & 1 else 2 + r)
main()


(n, m, k) = [int(x) for x in input().split()]
if k < n:
	print(k + 1, 1)
else:
	k += 1
	row_num = (k - n - 1) // (m - 1)
	col_num = (k - n - 1) % (m - 1)
	if row_num % 2:
		print(n - row_num, m - col_num)
	else:
		print(n - row_num, col_num + 2)


(H, W, K) = map(int, input().split())
if K < H:
	print(K + 1, 1)
	exit()
K -= H
W -= 1
(d, m) = divmod(K, W * 2)
if m < W:
	print(H - 2 * d, 2 + m)
else:
	m -= W
	print(H - 1 - 2 * d, W - m + 1)


(n, m, k) = map(int, input().split())
if k <= n - 1:
	print(k + 1, 1)
	exit(0)
k -= n
m -= 1
l = k // m
c = k % m
if l % 2 == 1:
	c = m - 1 - c
l = n - l
print(l, c + 2)


(n, m, k) = map(int, input().split())
if k > n - 1:
	k = k - n
	i = n
	j = 2
	cnt = k // (m - 1)
	res = k % (m - 1)
	if cnt % 2 == 1:
		j = m - res
		i = n - cnt
	else:
		j = 2 + res
		i = n - cnt
	print(i, end=' ')
	print(j)
else:
	i = 1 + k
	j = 1
	print(i, end=' ')
	print(j)


(n, m, k) = map(int, input().split())
if k <= n - 1:
	print(1 + k, 1)
elif k <= n + m - 2:
	print(n, k - (n - 1) + 1)
else:
	k -= n - 1
	k -= m - 1
	step = 1 + m - 2 + 1 + m - 2
	dy = k // (step // 2)
	y = n - dy
	if k % (step // 2):
		y -= 1
	k %= step
	if k == 0:
		x = m
	else:
		k -= 1
		if k <= m - 2:
			x = m - k
		else:
			k -= 1 + m - 2
			x = 1 + k + 1
	print(y, x)


(n, m, k) = map(int, input().split())
if True:
	if k < n:
		print(k + 1, 1)
	elif n + m - 1 > k:
		print(n, k - n + 2)
	else:
		k -= n + m - 1
		(x, y) = divmod(k, (m - 1) * 2)
		if y < m - 1:
			print(n - 1 - x * 2, m - y)
		else:
			print(n - 2 - x * 2, 2 + y - m + 1)


data = list(map(int, input().split()))
n = data[0]
m = data[1]
k = data[2]
pos = [1, 1]
if k <= n - 1:
	print(k + 1, 1)
else:
	k -= n - 1
	ans = k // (m - 1)
	pos = k % (m - 1)
	if pos == 0 and ans % 2 == 0:
		print(n - ans + 1, 2)
	elif pos == 0 and ans % 2 != 0:
		print(n - ans + 1, m)
	elif pos != 0 and ans % 2 == 0:
		print(n - ans, 1 + k % (2 * m - 2))
	else:
		print(n - ans, 2 + (2 * m - 2) - k % (2 * m - 2))


import sys
(N, M, K) = map(int, sys.stdin.readline().strip().split())
if K < N:
	print(K + 1, 1)
else:
	K -= N
	M -= 1
	if K // M % 2 == 0:
		print(N - K // M, 2 + K % M)
	else:
		print(N - K // M, 1 + M - K % M)


(n, m, k) = [int(x) for x in input().split()]
k += 1
if k <= n:
	print('%d 1' % k)
else:
	k -= n
	l = (k - 1) // (m - 1)
	lres = n - l
	r = k % (m - 1)
	if l % 2 == 0:
		rres = 1 + r
		if r == 0:
			rres = m
	elif r == 0:
		rres = 2
	else:
		rres = m - r + 1
	print('%d %d' % (lres, rres))


def res(n, m, k):
	if k < n:
		x = k + 1
		y = 1
		return str(x) + ' ' + str(y)
	lev = (k - n) // (m - 1)
	if lev % 2 == 0:
		x = n - lev
		y = (k - n) % (m - 1) + 2
		return str(x) + ' ' + str(y)
	if lev % 2 == 1:
		x = n - lev
		y = m - (k - n) % (m - 1)
		return str(x) + ' ' + str(y)
(n, m, k) = map(int, input().split())
print(res(n, m, k))


(n, m, k) = map(int, input().split())
if k <= n - 1:
	print(k + 1, 1)
	return
k -= n
m -= 1
l = k // m
c = k % m
if l % 2 == 1:
	c = m - 1 - c
l = n - l
print(l, c + 2)


def main():
	(n, m, k) = map(int, input().split())
	if 0 <= k < n:
		r = k + 1
		c = 1
	else:
		p = k - (n - 1)
		(x, y) = divmod(p, m - 1)
		x = x if y == 0 else x + 1
		if x % 2 == 1:
			c = m if y == 0 else y + 1
		else:
			c = 2 if y == 0 else m - (y - 1)
		r = n - x + 1
	print(r, c)
main()


def solve(n, m, k):
	if k < n:
		return (k + 1, 1)
	else:
		kk = k - n
		mm = m - 1
		kc = kk % mm
		kr = kk // mm
		if kr % 2 == 0:
			return (n - kr, 2 + kc)
		else:
			return (n - kr, m - kc)
(n, m, k) = [int(s) for s in input().split()]
(x, y) = solve(n, m, k)
print(x, y)


import sys
import math
import bisect
import itertools
(n, m, k) = map(int, sys.stdin.readline().strip().split(' '))
if k < n:
	print(k + 1, 1)
elif k == n:
	print(n, 2)
else:
	k -= n
	q = k // (m - 1)
	r = k % (m - 1)
	if q % 2 == 0:
		print(n - q, 2 + r)
	else:
		print(n - q, m - r)


(n, m, k) = map(int, input().split())
if k <= n - 1:
	print(k + 1, 1)
	exit()
r = m - 1
ma = n * r
k1 = k - n + 1
if k1 >= ma:
	print(1, 2)
	exit()
p = k1 // r
if k1 % r != 0:
	p += 1
k1 -= (m - 1) * (p - 1)
if abs(n - p) % 2 != 0:
	print(n - p + 1, k1 + 1)
else:
	print(n - p + 1, m - k1 + 1)


(n, m, k) = map(int, input().split())
if k < n:
	print(k + 1, 1)
else:
	full_lines = (k - n + 1) // (m - 1)
	position = (k - n + 1) % (m - 1)
	height = n - full_lines + (1 if position == 0 else 0)
	if full_lines % 2 == 1:
		if position == 0:
			width = m
		else:
			width = m - position + 1
	elif position == 0:
		width = 2
	else:
		width = 1 + position
	print(height, width)