Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).

Valera wants to place exactly k tubes on his rectangle table. A tube is such sequence of table cells (x_1, y_1), (x_2, y_2), ..., (x_{r}, y_{r}), that:   r ≥ 2;  for any integer i (1 ≤ i ≤ r - 1) the following equation |x_{i} - x_{i} + 1| + |y_{i} - y_{i} + 1| = 1 holds;  each table cell, which belongs to the tube, must occur exactly once in the sequence. 

Valera thinks that the tubes are arranged in a fancy manner if the following conditions are fulfilled:   no pair of tubes has common cells;  each cell of the table belongs to some tube. 

Help Valera to arrange k tubes on his rectangle table in a fancy manner.


-----Input-----

The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly. 


-----Output-----

Print k lines. In the i-th line print the description of the i-th tube: first print integer r_{i} (the number of tube cells), then print 2r_{i} integers x_{i}1, y_{i}1, x_{i}2, y_{i}2, ..., x_{ir}_{i}, y_{ir}_{i} (the sequence of table cells).

If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution exists. 


-----Examples-----
Input
3 3 3

Output
3 1 1 1 2 1 3
3 2 1 2 2 2 3
3 3 1 3 2 3 3

Input
2 3 1

Output
6 1 1 1 2 1 3 2 3 2 2 2 1



-----Note-----

Picture for the first sample:  [Image] 

Picture for the second sample:  [Image]

Difficulty: MEDIUM
Tags: Graph traversal

Implementation

Constructive algorithms

Starter code:

Solutions:
(n, m, k) = map(int, input().split())
r = []
for i in range(n):
	for j in range(m)[::-(i % 2) * 2 + 1]:
		r += [str(i + 1), str(j + 1)]
chunk = m * n // k
for i in range(k - 1):
	print(chunk, ' '.join(r[2 * i * chunk:2 * (i + 1) * chunk]))
print((len(r) - 2 * (k - 1) * chunk) // 2, ' '.join(r[2 * (k - 1) * chunk:]))


(n, m, k) = map(int, input().split())
(curx, cury) = (1, 1)
flag = 1

def construct(lim):
	cnt = 0
	global curx, cury, flag
	while cnt < lim:
		cnt += 1
		if curx > n or cury > m:
			break
		if flag != 0:
			print(curx, cury, end=' ')
			cury += 1
			if cury > m:
				flag = 0
				cury = m
				curx += 1
		elif flag == 0:
			print(curx, cury, end=' ')
			cury -= 1
			if cury < 1:
				curx += 1
				cury = 1
				flag = 1
	print()
for _ in range(1, k):
	print(2, end=' ')
	construct(2)
print(m * n - (k - 1) * 2, end=' ')
construct(m * n - (k - 1) * 2)


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

def z():
	for i in range(n):
		for j in range(m):
			if i % 2 == 0:
				yield (i + 1, j + 1)
			else:
				yield (i + 1, m - j)

def p(a):
	print(len(a), ' '.join(('{} {}'.format(x, y) for (x, y) in a)))
a = list(z())
l = n * m // k
for i in range(k - 1):
	p(a[i * l:(i + 1) * l])
p(a[l * (k - 1):])


(n, m, k) = map(int, input().split())
(i, j, res) = (1, 1, [])
while i <= n:
	if j < 1 or j > m:
		i += 1
		j += 1 if i % 2 == 1 else -1
	if i > n:
		break
	res.append(str(i) + ' ' + str(j))
	j += 1 if i % 2 == 1 else -1
d = len(res) // k
for i in range(k - 1):
	print(d, ' '.join(res[i * d:i * d + d]))
if k == 1:
	i = -1
res = res[i * d + d:]
print(len(res), ' '.join(res))


(n, m, k) = map(int, input().split())
mat = [[0 for i in range(m)] for i in range(n)]
l = []
for i in range(n):
	if i % 2 == 0:
		for j in range(m):
			l.append(str(i + 1) + ' ' + str(j + 1))
	else:
		for j in range(m - 1, -1, -1):
			l.append(str(i + 1) + ' ' + str(j + 1))
start = 0
for i in range(k - 1):
	print(2, ' '.join(l[start:start + 2]))
	start += 2
print(n * m - 2 * (k - 1), ' '.join(l[start:]))


(n, m, k) = map(int, input().split())
lst = []
for i in range(1, n + 1):
	if i % 2 == 1:
		for j in range(1, m + 1):
			lst.append(str(i) + ' ' + str(j))
	else:
		for j in range(m, 0, -1):
			lst.append(str(i) + ' ' + str(j))
q = m * n // k
r = m * n % k
for i in range(k):
	if i == k - 1:
		print(q + r, ' '.join(lst[q * i:]))
		break
	print(q, ' '.join(lst[q * i:q * (i + 1)]))


import math
a = []
(n, m, k) = map(int, input().split())
for i in range(1, n + 1):
	if i % 2 == 1:
		for j in range(1, m + 1):
			a.append([i, j])
	else:
		for j in range(m, 0, -1):
			a.append([i, j])
x = 1
i = 0
while x <= k - 1:
	print(2, end=' ')
	for j in range(i, i + 2):
		print(*a[j], end=' ')
	i += 2
	x += 1
	print()
print(n * m - 2 * (k - 1), end=' ')
for j in range(i, len(a)):
	print(*a[j], end=' ')


(row, column, tubes) = input().split(' ')
row = int(row)
column = int(column)
tube = int(tubes)
flag = bool(1)
k = int(1)
x = int(1)
res = int(row * column / tube)
if res < 2:
	res = int(2)
for i in range(1, tube, 1):
	print(res, '', end='')
	for j in range(0, res, 1):
		if k >= 1 and k <= column:
			print(x, k, '', end='')
			k = k + flag
		if k > column:
			k = column
			x = x + 1
			flag = -1
		if k < 1:
			k = 1
			x = x + 1
			flag = 1
	print('')
res = row * column - (tube - 1) * res
print(res, '', end='')
for i in range(0, res, 1):
	if k >= 1 and k <= column:
		print(x, k, '', end='')
		k = k + flag
	if k > column:
		k = column
		x = x + 1
		flag = -1
	if k < 1:
		k = 1
		x = x + 1
		flag = 1
print('')


def print_tube(a):
	print(len(a), end=' ')
	print(' '.join(map(lambda x: ' '.join((str(i) for i in x)), a)))
(n, m, k) = map(int, input().split())
res = [(x + 1, y + 1) for x in range(n) for y in range(m)[::1 if x % 2 == 0 else -1]]
for i in range(k - 1):
	print_tube(res[2 * i:2 * i + 2])
print_tube(res[2 * k - 2:])


from collections import defaultdict, deque, Counter, OrderedDict

def main():
	(n, m, k) = map(int, input().split())
	(l, ans) = ([], [])
	for i in range(1, n + 1):
		if i % 2 == 0:
			for j in range(m, 0, -1):
				l.append((i, j))
		else:
			for j in range(1, m + 1):
				l.append((i, j))
	curr = 0
	while k > 1:
		ans.append([l[curr][0], l[curr][1], l[curr + 1][0], l[curr + 1][1]])
		curr += 2
		k -= 1
	ans.append([])
	for i in range(curr, len(l)):
		ans[-1].append(l[i][0])
		ans[-1].append(l[i][1])
	for i in ans:
		print(len(i) // 2, ' '.join(map(str, i)))

def __starting_point():
	main()
__starting_point()


from math import *
from collections import *
from random import *
from bisect import *
import sys
input = sys.stdin.readline

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

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

def inp():
	return int(input())
(n, m, k) = ma()
tu = 0
re = 0
an = []
mo = 0
loc = []
for i in range(n):
	for j in range(m):
		if re != k - 1:
			if i % 2 == 0:
				mo += 1
				loc.extend([i + 1, j + 1])
				if mo == 2:
					mo = 0
					re += 1
					an.append(loc)
					loc = []
			else:
				mo += 1
				loc.extend([i + 1, m - j])
				if mo == 2:
					mo = 0
					re += 1
					an.append(loc)
					loc = []
		elif i % 2 == 0:
			loc.extend([i + 1, j + 1])
		else:
			loc.extend([i + 1, m - j])
an.append(loc)
for i in range(k):
	print(len(an[i]) // 2, *an[i])


(n, m, k) = map(int, input().split())
(d, s, p) = (0, [], [list(map(str, range(1, m + 1)))])
p.append(list(reversed(p[0])))
for i in map(str, range(1, n + 1)):
	s += [i + ' ' + j for j in p[d]]
	d = 1 - d
d = 2 * k - 2
for i in range(0, d, 2):
	print(2, s[i] + ' ' + s[i + 1])
print(n * m - d, ' '.join(s[d:]))


(n, m, k) = map(int, input().split())
val = n * m - 2 * (k - 1)
print(val, end=' ')
cnt = 0
turn = 1
lst = []
while turn <= n:
	if turn % 2 == 0:
		j = m
	else:
		j = 1
	while j <= m and j >= 1:
		if cnt == val:
			lst.append([turn, j])
			if turn % 2 == 0:
				j -= 1
			else:
				j += 1
		else:
			cnt += 1
			if cnt == val:
				print(turn, j)
			else:
				print(turn, j, end=' ')
			if turn % 2 == 0:
				j -= 1
			else:
				j += 1
	turn += 1
c = 0
itert = 2 * (k - 1)
while c < 2 * (k - 1):
	print(2, *lst[c], *lst[c + 1])
	c += 2


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

def printTube(tube):
	print(len(tube), end=' ')
	for cell in tube:
		print(cell[0] + 1, cell[1] + 1, end=' ')
	print()
nbTubes = 0
currTube = []
for i in range(n):
	if i % 2 == 0:
		jDomain = range(m)
	else:
		jDomain = reversed(range(m))
	for j in jDomain:
		currTube.append((i, j))
		if len(currTube) >= 2 and nbTubes < k - 1:
			printTube(currTube)
			currTube = []
			nbTubes += 1
printTube(currTube)


from collections import deque

def solve(n, m, k):
	arr = []
	for i in range(1, n + 1):
		if i % 2 != 0:
			for j in range(1, m + 1):
				arr.append(i)
				arr.append(j)
		else:
			for j in reversed(range(1, m + 1)):
				arr.append(i)
				arr.append(j)
	arr = deque(arr)
	while k > 1:
		print(2, arr.popleft(), arr.popleft(), arr.popleft(), arr.popleft())
		k -= 1
	print(len(arr) // 2, ' '.join(map(str, arr)))
A = list(map(int, input().split()))
solve(A[0], A[1], A[2])


(n, m, k) = map(int, input().split())
ans = []
for i in range(k):
	ans.append([] * k)
temp = k
x = 1
y = 1
count = 0
i = 0
bo = 0
while bo != n * m:
	if count == 2 and k != 1:
		count = 0
		k -= 1
		i += 1
	ans[i].append(x)
	ans[i].append(y)
	if x % 2 != 0:
		if y == m:
			x += 1
		else:
			y += 1
	elif y == 1:
		x += 1
	else:
		y -= 1
	count += 1
	bo += 1
for i in range(temp):
	print(len(ans[i]) // 2, *ans[i])


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))

def new_point_generator(n, m):
	(i, j) = (0, 0)
	yield f'{i + 1} {j + 1}'
	while True:
		if j + 1 < m and i % 2 == 0:
			j += 1
		elif j - 1 >= 0 and i % 2 == 1:
			j -= 1
		yield f'{i + 1} {j + 1}'
		if j == m - 1 or j == 0:
			i += 1
			yield f'{i + 1} {j + 1}'

def solve():
	(n, m, k) = read_tuple(int)
	cells = n * m
	cells_for_pipe = [cells // k for _ in range(k)]
	cells_for_pipe[0] += cells % k
	cells_for_pipe = iter(cells_for_pipe)
	filled = 0
	point_generator = new_point_generator(n, m)
	while filled < cells:
		_len = next(cells_for_pipe)
		print(_len, end=' ')
		for _ in range(_len):
			print(next(point_generator), end=' ')
		filled += _len
		print()
solve()


import os, sys
from io import BytesIO, IOBase

def main():
	(n, m, k) = map(int, input().split())
	an = []
	v = 1
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			if v:
				an.append((i, j))
			else:
				an.append((i, m + 1 - j))
		v ^= 1
	an.reverse()
	while k != 1:
		xx = [2, an[-1][0], an[-1][1], an[-2][0], an[-2][1]]
		an.pop()
		an.pop()
		print(*xx)
		k -= 1
	xx = []
	while len(an):
		xxx = an.pop()
		xx.extend([xxx[0], xxx[1]])
	xx = [len(xx) // 2] + xx
	print(*xx)
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')
main()


(n, m, k) = map(int, input().split())
c = 0
ans = []
count = 0
for i in range(1, n + 1):
	if c % 2 == 0:
		for j in range(1, m + 1):
			ans.append((i, j))
		c += 1
	else:
		for j in range(m, 0, -1):
			ans.append((i, j))
		c += 1
l = len(ans)
done = 0
for i in range(k - 1):
	print(l // k, end=' ')
	for j in range(l // k):
		done += 1
		print(ans[-1][0], ans[-1][1], end=' ')
		del ans[-1]
	print()
print(l - done, end=' ')
for i in range(l - done):
	print(ans[-1][0], ans[-1][1], end=' ')
	del ans[-1]
print()


import sys
f = sys.stdin
(n, m, k) = map(int, f.readline().strip().split())
ki = 1
ps = []
l = 0
p = []
for i in range(1, n + 1):
	if i % 2 == 0:
		r = range(m, 0, -1)
	else:
		r = range(1, m + 1)
	for j in r:
		p.append(str(i))
		p.append(str(j))
		l += 1
		if ki < k and l == 2:
			ps.append('2 ' + ' '.join(p))
			l = 0
			p = []
			ki += 1
ps.append(str(l) + ' ' + ' '.join(p))
print('\n'.join(ps))


(n, m, k) = map(int, input().split())
s = n * m // k
s1 = s + n * m - s * k
l = []
for i in range(1, n + 1):
	for j in range(1, m + 1):
		if i % 2 == 1:
			l.append((i, j))
		else:
			l.append((i, m + 1 - j))
c = 0
while k > 0:
	if k == 1:
		print(s1, end=' ')
		k -= 1
		for i in range(c, n * m):
			print(l[i][0], l[i][1], end=' ')
	else:
		print(s, end=' ')
		k -= 1
	if k >= 1:
		for i in range(s):
			print(l[c][0], l[c][1], end=' ')
			c += 1
		print(' ')


(x, y, k) = map(int, input().split(' '))

def nxt(lst):
	a = lst[0]
	b = lst[1]
	if not (1 <= a <= x and 1 <= b <= y):
		return [-420420, -420]
	if a % 2 == 1 and b == y:
		return [a + 1, b]
	if a % 2 == 0 and b == 1:
		return [a + 1, b]
	if a % 2 == 0:
		return [a, b - 1]
	else:
		return [a, b + 1]
a = [1, 1]
for i in range(k - 1):
	a1 = a[0]
	a2 = a[1]
	a = nxt(a)
	a3 = a[0]
	a4 = a[1]
	a = nxt(a)
	print(2, a1, a2, a3, a4)
xx = []
print(x * y - 2 * (k - 1), end=' ')
while nxt(a) != [-420420, -420]:
	print(a[0], a[1], end=' ')
	a = nxt(a)


(n, m, k) = map(int, input().split())
ans = []
i = 1
j = 1
gg = n * m // 2
for g in range(gg):
	if i % 2 != 0:
		if j != m:
			ans.append([i, j, i, j + 1])
			j += 2
			if j == m + 1:
				j = m
				i += 1
		else:
			ans.append([i, j, i + 1, m])
			i += 1
			j = m - 1
	elif j != 0:
		ans.append([i, j, i, j - 1])
		j -= 2
		if j == 0:
			j = 1
			i += 1
	else:
		ans.append([i, j, i + 1, 1])
		j = 2
		i += 1
(x, y, z, q) = ans[-1]
if n % 2 != 0 and q != m:
	ans[-1] += [n, m]
elif n % 2 == 0 and q != 1:
	ans += [n, 1]
aa = []
c = 1
for i in ans[:k - 1]:
	print(len(i) // 2, end=' ')
	print(*i)
for i in ans[k - 1:]:
	aa += i
print(len(aa) // 2, end=' ')
print(*aa)


(n, m, k) = map(int, input().split())
ans = []
i = j = 1
while i <= n:
	if j < 1 or j > m:
		i += 1
		j += [-1, 1][i % 2]
	if i > n:
		break
	ans.append('{} {}'.format(i, j))
	j += [-1, 1][i % 2]
div = len(ans) // k
i = -1
for i in range(k - 1):
	print(div, ' '.join(ans[i * div:(i + 1) * div]))
ans = ans[(i + 1) * div:]
print(len(ans), ' '.join(ans))


(n, m, k) = map(int, input().split())
l = []
for i in range(n):
	for j in range(m)[::[1, -1][i % 2]]:
		l += [str(i + 1), str(j + 1)]
p = m * n // k
for i in range(k - 1):
	print(p, ' '.join(l[2 * p * i:2 * p * (i + 1)]))
print(m * n - p * (k - 1), ' '.join(l[2 * p * (k - 1):]))


def ValeraAndTubes(n, m, k):
	minCellsPerTube = n * m // k
	l = n * m % k + minCellsPerTube
	reqLength = minCellsPerTube
	i = 1
	j = 1
	result = str(reqLength) + ' '
	while i <= n:
		if j > m:
			j = m
		elif j == 0:
			j = 1
		if i % 2 != 0:
			while j <= m:
				reqLength -= 1
				result += str(i) + ' ' + str(j) + ' '
				if reqLength == 0:
					print(result)
					k -= 1
					if k == 1:
						reqLength = l
					else:
						reqLength = minCellsPerTube
					result = str(reqLength) + ' '
				j += 1
		else:
			while j > 0 and k > 0:
				reqLength -= 1
				result += str(i) + ' ' + str(j) + ' '
				if reqLength == 0:
					print(result)
					k -= 1
					if k == 1:
						reqLength = l
					else:
						reqLength = minCellsPerTube
					result = str(reqLength) + ' '
				j -= 1
		i += 1
(n, m, k) = [int(x) for x in input().split()]
ValeraAndTubes(n, m, k)


(n, m, k) = list(map(int, input().split()))
unit_tube = n * m // k
long_tube = n * m % k + unit_tube
print(long_tube, end='')
i = 0
j = 0
ref = 0
for _ in range(long_tube):
	print(' {0} {1}'.format(i + 1, abs(j + 1 - ref)), end='')
	if (j + 1) % m == 0:
		i += 1
		ref = 0 if ref else m + 1
	j = (j + 1) % m
print()
for _ in range(k - 1):
	print(unit_tube, end='')
	for _ in range(unit_tube):
		print(' {0} {1}'.format(i + 1, abs(j + 1 - ref)), end='')
		if (j + 1) % m == 0:
			i += 1
			ref = 0 if ref else m + 1
		j = (j + 1) % m
	print()


(n, m, k) = [int(x) for x in input().split()]
i = 0
currx = 1
curry = 1
x = 1
while i < k:
	if i == k - 1:
		ans = []
		while currx <= n and curry <= m:
			ans.append([currx, curry])
			if curry == 1 and x == -1:
				currx += 1
				x = 1
			elif curry == m and x == 1:
				currx += 1
				x = -1
			else:
				curry += x
		print(len(ans), end=' ')
		for i in ans:
			print(i[0], i[1], end=' ')
		break
	else:
		print(2, end=' ')
		print(currx, curry, end=' ')
		if curry == 1 and x == -1:
			currx += 1
			x = 1
		elif curry == m and x == 1:
			currx += 1
			x = -1
		else:
			curry += x
		print(currx, curry)
		if curry == 1 and x == -1:
			currx += 1
			x = 1
		elif curry == m and x == 1:
			currx += 1
			x = -1
		else:
			curry += x
		i += 1


(n, m, k) = [int(i) for i in input().split()]
cur = 0
colored = 0
a = [[0] * m for i in range(n)]
res = [[] for i in range(k)]
for i in range(0, n - 1, 2):
	for j in range(m):
		if colored == 2:
			cur = min(cur + 1, k - 1)
			colored = 0
		res[cur].append(i)
		res[cur].append(j)
		colored += 1
	for j in range(m - 1, -1, -1):
		if colored == 2:
			colored = 0
			cur = min(cur + 1, k - 1)
		res[cur].append(i + 1)
		res[cur].append(j)
		colored += 1
if n % 2 == 1:
	for j in range(m):
		if colored == 2:
			colored = 0
			cur = min(cur + 1, k - 1)
		res[cur].append(n - 1)
		res[cur].append(j)
		colored += 1
for i in res:
	print(len(i) // 2, end=' ')
	print(' '.join([str(j + 1) for j in i]))


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, m, k) = I()
r = 0
cc = [1, 1]
tot = 0
an = [[] for i in range(k)]
while r != k:
	an[r] += cc
	tot += 1
	if len(an[r]) == 4:
		r += 1
	while r == k - 1 and tot < n * m:
		cc = [cc[0] + 1, cc[1]] if cc[0] % 2 and cc[1] == m or (cc[0] % 2 == 0 and cc[1] == 1) else [cc[0], cc[1] + (1 if cc[0] % 2 else -1)]
		an[r] += cc
		tot += 1
	if tot == n * m:
		break
	cc = [cc[0] + 1, cc[1]] if cc[0] % 2 and cc[1] == m or (cc[0] % 2 == 0 and cc[1] == 1) else [cc[0], cc[1] + (1 if cc[0] % 2 else -1)]
for i in an:
	print(len(i) // 2, *i)


(a, b, c) = map(int, input().split())
l = []
for i in range(a):
	for j in range(b)[::[1, -1][i % 2]]:
		l += [str(i + 1), str(j + 1)]
p = b * a // c
for i in range(c - 1):
	print(p, ' '.join(l[2 * p * i:2 * p * (i + 1)]))
print(b * a - p * (c - 1), ' '.join(l[2 * p * (c - 1):]))


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase
from fractions import *

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

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

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, m, k) = value()
(r, c) = (0, 0)
flag = 1
for i in range(k - 1):
	print(2, end=' ')
	print(r + 1, c + 1, r + 1 + 1, c + 1)
	c += 1
	if c == m:
		c = 0
		r += 2
	if r + 2 > n:
		flag = 0
		break
if flag == 1:
	print((m - c) * 2 + (n - r - 2) * m, end=' ')
	temp = c - 1
	c = m - 1
	while c != temp and r < n:
		print(r + 1, c + 1, end=' ')
		c -= 1
	r += 1
	c += 1
	while c != m and r < n:
		print(r + 1, c + 1, end=' ')
		c += 1
	r += 1
	f = 0
	for i in range(r, n):
		if f == 0:
			f = 1
			for j in range(m - 1, -1, -1):
				print(i + 1, j + 1, end=' ')
		else:
			f = 0
			for j in range(m):
				print(i + 1, j + 1, end=' ')
else:
	rem = k - i - 1
	for i in range(rem - 1):
		print(2, end=' ')
		print(r + 1, c + 1, end=' ')
		c += 1
		print(r + 1, c + 1)
		c += 1
	print(m - c, end=' ')
	while c != m:
		print(r + 1, c + 1, end=' ')
		c += 1


def main():
	(n, m, k) = map(int, input().split())
	(pipe, res) = ([], [])
	for y in range(1, n + 1):
		for x in range(1, m + 1) if y & 1 else range(m, 0, -1):
			pipe.append(str(y))
			pipe.append(str(x))
	for i in range(0, k * 4 - 4, 4):
		res.append('2 ')
		res.append(' '.join(pipe[i:i + 4]))
		res.append('\n')
	res.append(str(n * m - k * 2 + 2) + ' ')
	res.append(' '.join(pipe[k * 4 - 4:]))
	print(''.join(res))
main()


inn = input()
inn = list(map(int, inn.split()))
n = inn[0]
m = inn[1]
k = inn[2]
filas = []
cols = []
for i in range(0, n):
	for j in range(0, m):
		filas.append(i + 1)
		if i % 2 == 0:
			cols.append(j + 1)
		else:
			cols.append(m - j)
pos = 0
for i in range(0, k - 1):
	print(2, filas[pos], cols[pos], filas[pos + 1], cols[pos + 1])
	pos += 2
print(n * m - 2 * (k - 1), end='')
while pos < n * m:
	print(' ', end='')
	print(filas[pos], end='')
	print(' ', end='')
	print(cols[pos], end='')
	pos += 1


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
(a, b, c) = map(int, input().split())
l = []
for i in range(a):
	for j in range(b)[::[1, -1][i % 2]]:
		l += [str(i + 1), str(j + 1)]
p = b * a // c
for i in range(c - 1):
	print(p, ' '.join(l[2 * p * i:2 * p * (i + 1)]))
print(b * a - p * (c - 1), ' '.join(l[2 * p * (c - 1):]))
endtime = time.time()


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)

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

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

def input():
	return sys.stdin.readline().strip()
(n, m, k) = get_ints()
mat = [[0 for i in range(m)] for j in range(n)]
light = 1
flag = 0
count = 0
for i in range(n):
	if flag == 0:
		for j in range(m):
			mat[i][j] = light
			count += 1
			if count == 2 and light != k:
				count = 0
				light += 1
		flag = 1
	else:
		for j in range(m - 1, -1, -1):
			mat[i][j] = light
			count += 1
			if count == 2 and light != k:
				count = 0
				light += 1
		flag = 0
ans = [[] for i in range(k + 1)]
flag = 0
for i in range(n):
	if flag == 0:
		for j in range(m):
			ans[mat[i][j]].append(i + 1)
			ans[mat[i][j]].append(j + 1)
		flag = 1
	else:
		for j in range(m - 1, -1, -1):
			ans[mat[i][j]].append(i + 1)
			ans[mat[i][j]].append(j + 1)
		flag = 0
for i in ans[1:]:
	print(len(i) // 2, end=' ')
	print(*i)


(sizeI, sizeJ, n) = map(int, input().split())
turn = 0
curI = curJ = 1
a = [[] for _ in range(n)]

def paint(pos):
	global curI, curJ, turn
	a[pos].extend((curI, curJ))
	if turn == 0:
		if curJ == sizeJ:
			curI += 1
			turn ^= 1
		else:
			curJ += 1
	elif curJ == 1:
		curI += 1
		turn ^= 1
	else:
		curJ -= 1
for i in range(n):
	while len(a[i]) < 4:
		paint(i)
while curI <= sizeI:
	paint(-1)
for row in a:
	print('%d %s' % (len(row) // 2, ' '.join(map(str, row))))


def main():
	from sys import stdin, stdout
	(n, m, k) = list(map(int, stdin.readline().split()))
	if n >= m:
		i = -1
		j = -1
		num = n * m
		while k:
			ans = num // k
			stdout.write(str(ans) + ' ')
			counter = 0
			while counter < ans:
				if j == -1:
					flag = True
					i += 1
					j += 1
				if j == m:
					flag = False
					i += 1
					j -= 1
				stdout.write(str(i + 1) + ' ' + str(j + 1) + ' ')
				if flag:
					j += 1
				else:
					j -= 1
				counter += 1
			num -= ans
			k -= 1
			stdout.write('\n')
	else:
		i = -1
		j = -1
		num = n * m
		while k:
			ans = num // k
			stdout.write(str(ans) + ' ')
			counter = 0
			while counter < ans:
				if i == -1:
					flag = True
					j += 1
					i += 1
				if i == n:
					flag = False
					j += 1
					i -= 1
				stdout.write(str(i + 1) + ' ' + str(j + 1) + ' ')
				if flag:
					i += 1
				else:
					i -= 1
				counter += 1
			num -= ans
			k -= 1
			stdout.write('\n')

def __starting_point():
	main()
__starting_point()


(n, m, k) = [int(x) for x in input().split()]
l = []
for i in range(k - 1):
	lll = ['2']
	l.append(lll)
x = m * n - 2 * k + 2
ll = [str(x)]
l.append(ll)
num = 0
for i in range(1, n + 1):
	if i % 2 == 1:
		for j in range(1, m + 1):
			if num < 2 * k - 2:
				li = [i, j]
				s = int(((i - 1) * m + j - 1) / 2)
				l[s].extend(li)
				num += 1
			else:
				li = [i, j]
				l[-1].extend(li)
				num += 1
	else:
		for j in range(1, m + 1):
			if num < 2 * k - 2:
				li = [i, m + 1 - j]
				s = int(((i - 1) * m + j - 1) / 2)
				l[s].extend(li)
				num += 1
			else:
				li = [i, m + 1 - j]
				l[-1].extend(li)
				num += 1
for i in range(k):
	lst = l[i]
	for j in range(len(lst)):
		lst[j] = str(lst[j])
	print(' '.join(lst))


def valera_and_tube(n, m, k):
	snake = []
	x = 1
	for y in range(1, m + 1):
		if x == 1:
			start = 1
			stop = n + 1
			step = 1
		else:
			start = n
			stop = 0
			step = -1
		for x in range(start, stop, step):
			snake.append((x, y))
	i = 0
	for i in range(2, 2 * k, 2):
		print(2, *snake[i - 2], *snake[i - 1])
	print(len(snake) - i, *[' '.join(map(str, x)) for x in snake[i:]])
(n, m, k) = map(int, input().strip().split())
valera_and_tube(n, m, k)


import sys
(n, m, k) = map(int, input().split())
solution = []
for i in range(1, n + 1):
	r = range(1, m + 1) if i % 2 == 1 else reversed(range(1, m + 1))
	for j in r:
		solution.append((i, j))
i = 0
for __ in range(k - 1):
	print('2 %d %d %d %d' % (solution[i][0], solution[i][1], solution[i + 1][0], solution[i + 1][1]))
	i += 2
print(n * m - (k - 1) * 2, end=' ')
while i < n * m:
	print('%d %d' % (solution[i][0], solution[i][1]), end=' ')
	i += 1


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import *
from math import *
(n, m, k) = readi()
totalTubes = int(n * m / k)
step = 1
cellCount = 0
for i in range(1, n + 1):
	if step == 1:
		for j in range(1, m + 1):
			if cellCount % totalTubes == 0 and cellCount // k < totalTubes:
				if cellCount != 0:
					print()
				if cellCount // totalTubes < k - 1:
					print(totalTubes, end=' ')
				else:
					print(m * n - cellCount, end=' ')
			print(i, j, end=' ')
			cellCount += 1
		step *= -1
	else:
		for j in range(m, 0, -1):
			if cellCount % totalTubes == 0 and cellCount // k < totalTubes:
				if cellCount != 0:
					print()
				if cellCount // totalTubes < k - 1:
					print(totalTubes, end=' ')
				else:
					print(m * n - cellCount, end=' ')
			print(i, j, end=' ')
			cellCount += 1
		step *= -1


(n, m, k) = [int(i) for i in input().split()]
import sys
seq = []
rev = False
for i in range(n):
	l = list(zip([i + 1] * m, range(1, m + 1)))
	if rev:
		l.reverse()
	seq += l
	rev = not rev
for i in range(k - 1):
	sys.stdout.write('2 ' + str(seq[i * 2][0]) + ' ' + str(seq[i * 2][1]) + ' ' + str(seq[i * 2 + 1][0]) + ' ' + str(seq[i * 2 + 1][1]) + '\n')
print(len(seq) - k * 2 + 2, end=' ')
for (a, b) in seq[k * 2 - 2:]:
	sys.stdout.write(str(a) + ' ' + str(b) + ' ')


import sys, math, itertools, random, bisect
from collections import defaultdict
INF = 10 ** 18

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

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

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
test = 1
for _ in range(test):
	(n, m, k) = get_ints()
	row = 1
	col = 1
	right = True
	for i in range(k - 1):
		if right:
			if col == m:
				print(2, row, col, row + 1, col)
				col -= 1
				row += 1
				right = False
			elif col > m:
				row += 1
				col -= 1
				print(2, row, col, row, col - 1)
				col -= 2
				right = False
			else:
				print(2, row, col, row, col + 1)
				col += 2
		elif col == 1:
			print(2, row, col, row + 1, col)
			row += 1
			col += 1
			right = True
		elif col < 1:
			row += 1
			col += 1
			print(2, row, col, row, col + 1)
			col += 2
			right = True
		else:
			print(2, row, col, row, col - 1)
			col -= 2
	rem = n * m - 2 * (k - 1)
	ans = [rem]
	if col == m + 1 or col == 0:
		row += 1
		col = 1
		right = True
	for i in range(rem):
		if right:
			if col == m:
				ans.append(row)
				ans.append(col)
				row += 1
				right = False
			else:
				ans.append(row)
				ans.append(col)
				col += 1
		elif col == 1:
			ans.append(row)
			ans.append(col)
			row += 1
			right = True
		else:
			ans.append(row)
			ans.append(col)
			col -= 1
	print(*ans)


(n, m, k) = map(int, input().split())
x = 1
y = 1
a = [[1, 1]]
inv = 1
z = n * m
while z > 1:
	z -= 1
	if y < m and inv == 1:
		y += 1
	elif y > 1 and inv == -1:
		y -= 1
	else:
		x += 1
		inv = -inv
	a.append([x, y])
while k > 1:
	print(2, *a.pop(), end=' ')
	print(*a.pop())
	k -= 1
print(len(a), end=' ')
for i in a:
	print(*i, end=' ')
print()


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


from sys import stdin
firstline = stdin.readline().rstrip().split()
rows = int(firstline[0])
cols = int(firstline[1])
k = int(firstline[2])
flip = True
flat_matrix = []
for row in range(rows):
	col_traversal = (range(cols - 1, -1, -1), range(cols))[flip]
	for col in col_traversal:
		flat_matrix.append((row + 1, col + 1))
	flip = not flip
point = 0
for tube in range(k):
	if tube != k - 1:
		print('2 ', end='')
		for cell in range(2):
			point + cell
			print(str(flat_matrix[point + cell][0]) + ' ' + str(flat_matrix[point + cell][1]) + ' ', end='')
		point += 2
		print()
	else:
		print(str(len(flat_matrix) - point) + ' ', end='')
		for cell in range(len(flat_matrix) - point):
			print(str(flat_matrix[point + cell][0]) + ' ' + str(flat_matrix[point + cell][1]) + ' ', end='')
print()


from collections import Counter
import itertools
from functools import lru_cache
import sys
import math

def helper():
	pass

def solve():
	(n, m, k) = map(int, input().split(' '))
	(perCell, last) = (n * m // k, n * m % k)
	points = []
	turn = 0
	for i in range(1, n + 1):
		if turn == 0:
			for j in range(1, m + 1):
				points.append((i, j))
		else:
			for j in range(m, 0, -1):
				points.append((i, j))
		turn ^= 1
	index = 0
	for i in range(k - 1):
		print(perCell, end=' ')
		for j in range(perCell):
			print(points[index][0], points[index][1], end=' ')
			index += 1
		print()
	print(perCell + last, end=' ')
	for i in range(perCell + last):
		print(points[index][0], points[index][1], end=' ')
		index += 1
t = 1
for _ in range(t):
	solve()


import sys

def main():
	(n, m, k) = map(int, sys.stdin.readline().split(' '))
	l = []
	alt = False
	for i in range(n):
		if not alt:
			for j in range(m):
				l.append((i + 1, j + 1))
		else:
			for j in range(m - 1, -1, -1):
				l.append((i + 1, j + 1))
		alt ^= True
	length = n * m // k
	i = 0
	for j in range(1, k + 1):
		g = l[i:j * length]
		if j == k:
			g = l[i:]
		s = ' '.join(list(map(lambda x: ' '.join(map(str, x)), g)))
		sys.stdout.write('{} {}\n'.format(len(g), s))
		i = j * length
main()


(n, m, k) = [int(j) for j in input().split()]
a = []
c = k
for i in range(1, n + 1):
	if i % 2 != 0:
		for j in range(1, m + 1):
			a.append((i, j))
	else:
		for j in range(m, 0, -1):
			a.append((i, j))
for i in range(0, n * m, 2):
	if k > 1:
		print(2, *a[i], *a[i + 1])
	else:
		print(n * m - 2 * (c - 1), end=' ')
		for j in range(i, n * m):
			print(*a[j], end=' ')
		exit()
	k -= 1


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

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
import time
start_time = time.time()
import collections as col
import math
from functools import reduce

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

def getInt():
	return int(input())

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

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	(N, M, K) = getInts()
	(row, col, dr) = (1, 1, True)
	for k in range(K - 1):
		if dr:
			if col + 1 < M + 1:
				print(2, row, col, row, col + 1)
				if col + 2 < M + 1:
					col += 2
				else:
					row += 1
					col += 1
					dr = not dr
			else:
				print(2, row, col, row + 1, col)
				row += 1
				col -= 1
				dr = not dr
		elif col - 1 > 0:
			print(2, row, col, row, col - 1)
			if col - 2 > 0:
				col -= 2
			else:
				row += 1
				col -= 1
				dr = not dr
		else:
			print(2, row, col, row + 1, col)
			row += 1
			col += 1
			dr = not dr
	last_str = [str(N * M - 2 * (K - 1))]
	for _ in range(N * M - 2 * (K - 1)):
		last_str.append(str(row))
		last_str.append(str(col))
		if dr:
			if col + 1 < M + 1:
				col += 1
			else:
				row += 1
				dr = not dr
		elif col - 1 > 0:
			col -= 1
		else:
			row += 1
			dr = not dr
	print(' '.join(last_str))
	return
solve()


(n, m, d) = map(int, input().split())
a = []
for i in range(n):
	p = []
	if i % 2 == 0:
		for j in range(m):
			p.append([i + 1, j + 1])
	else:
		for j in range(m - 1, -1, -1):
			p.append([i + 1, j + 1])
	a.append(p)
f = []
for i in range(n):
	for j in range(m):
		f.append(a[i][j])
j = 0
for i in range(d - 1):
	print(2, *f[j], *f[j + 1], sep=' ')
	j += 2
print(n * m - j, end=' ')
while j < n * m:
	print(*f[j], end=' ')
	j += 1


(n, m, k) = map(int, input().split())
size = n * m // k
temp = []
tubes = []
count = 0
flag = True
for i in range(n):
	if flag:
		for j in range(m):
			temp.append((i + 1, j + 1))
			count += 1
			if count == size and len(tubes) < k - 1:
				tubes.append(temp)
				count = 0
				temp = []
		flag = False
	else:
		for j in reversed(range(m)):
			temp.append((i + 1, j + 1))
			count += 1
			if count == size and len(tubes) < k - 1:
				tubes.append(temp)
				count = 0
				temp = []
		flag = True
if temp:
	tubes.append(temp)
for t in tubes:
	s = str(len(t)) + ' '
	for p in t:
		s += str(p[0]) + ' ' + str(p[1]) + ' '
	print(s)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest

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

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

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

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
(n, m, k) = MAP()
total = n * m
foo = total // k
left = total - (k - 1) * foo
l = [foo] * (k - 1)
l.append(left)
x = y = 1
flag = 0
for el in l:
	print(el, end=' ')
	for temp in range(1, el + 1):
		if y > m:
			x += 1
			y -= 1
			flag = 1
		if y < 1:
			x += 1
			y += 1
			flag = 0
		print(x, y, end=' ')
		if flag == 0:
			y += 1
		else:
			y -= 1
	print()


def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return [int(x) for x in inputs.split()]

def write(s='\n'):
	if isinstance(s, list):
		s = ' '.join(s)
	s = str(s)
	print(s, end='')
(n, m, k) = read()
cells = []
for i in range(n):
	if not i % 2:
		for j in range(m):
			cells.append((i + 1, j + 1))
	else:
		for j in range(m - 1, -1, -1):
			cells.append((i + 1, j + 1))
ct = 0
for i in range(k - 1):
	print(2, cells[ct][0], cells[ct][1], cells[ct + 1][0], cells[ct + 1][1])
	ct += 2
print(len(cells) - ct, end=' ')
for i in cells[ct:]:
	print(i[0], i[1], end=' ')


import collections, itertools, fractions, functools, heapq, math, queue

def solve():
	(n, m, k) = map(int, input().split())
	cells = []
	for i in range(n):
		if i % 2 == 0:
			for j in range(m):
				cells.append((i + 1, j + 1))
		else:
			for j in range(m, 0, -1):
				cells.append((i + 1, j))
	for _ in range(k - 1):
		print(2, *cells[-1], *cells[-2])
		cells.pop()
		cells.pop()
	print(len(cells), end=' ')
	for c in cells:
		print(*c, end=' ')
	print()
solve()


def fucn(x, y, c):
	if x % 2:
		y = y + 1
		if y > c:
			x = x + 1
			y = c
	else:
		y = y - 1
		if y < 1:
			x = x + 1
			y = 1
	return (x, y)
scann = input()
x = 1
y = 1
acum = 0
arr = []
numbers = scann.split()
row = numbers[0]
column = numbers[1]
tube = numbers[2]
r = int(row)
c = int(column)
t = int(tube)
table = r * c
aux = int(table) / t
for i in range(t - 1):
	arr.append(int(aux))
	for j in range(int(aux)):
		arr.append(int(x))
		arr.append(int(y))
		(x, y) = fucn(x, y, c)
		acum = acum + 1
	print(*arr)
	arr = []
arr.append(table - acum)
new = table - acum
for k in range(int(new)):
	arr.append(int(x))
	arr.append(int(y))
	(x, y) = fucn(x, y, c)
print(*arr)


(n, m, k) = map(int, input().split())
(tem, ans, c, all) = ([], [], 1, 1)
for i in range(1, n + 1):
	(be, en, inc) = (1, m + 1, 1)
	if i % 2 == 0:
		(be, en, inc) = (m, 0, -1)
	for j in range(be, en, inc):
		tem.extend([i, j])
		if c == n * m // k:
			if all > n * m // k * k:
				ans[-1].extend(tem)
			else:
				ans.append(tem)
			(c, tem) = (0, [])
		c += 1
		all += 1
ans[-1].extend(tem)
for i in range(k):
	print(len(ans[i]) // 2, *ans[i], sep=' ')


(n, m, k) = list(map(int, input().split()))
result = []
for row in range(1, n + 1):
	if row & 1:
		for col in range(1, m + 1):
			result.append([row, col])
	else:
		for col in range(m, 0, -1):
			result.append([row, col])
i = 0
while i // 2 < k - 1:
	print(2, result[i][0], result[i][1], result[i + 1][0], result[i + 1][1])
	i += 2
print(len(result) - i, end=' ')
while i < len(result):
	print(result[i][0], result[i][1], end=' ')
	i += 1


from io import BytesIO, IOBase
from math import sqrt
import sys, os
from os import path
inpl = lambda : list(map(int, input().split()))
inpm = lambda : map(int, input().split())
inpi = lambda : int(input())
inp = lambda : input()
(rev, ra, l) = (reversed, range, len)
P = print
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

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

def factors(n):
	arr = []
	for i in ra(2, int(sqrt(n)) + 1):
		if n % i == 0:
			arr.append(i)
			if i * i != n:
				arr.append(int(n / i))
	return arr

def dfs(arr, n):
	pairs = [[i + 1] for i in ra(n)]
	vis = [0] * (n + 1)
	for i in ra(l(arr)):
		pairs[arr[i][0] - 1].append(arr[i][1])
	pairs[arr[i][1] - 1].append(arr[i][0])
	comp = []
	for i in ra(n):
		stack = [pairs[i]]
		temp = []
		if vis[stack[-1][0]] == 0:
			while len(stack) > 0:
				if vis[stack[-1][0]] == 0:
					temp.append(stack[-1][0])
					vis[stack[-1][0]] = 1
					s = stack.pop()
					for j in s[1:]:
						if vis[j] == 0:
							stack.append(pairs[j - 1])
				else:
					stack.pop()
			comp.append(temp)
	return comp
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys, operator, math, operator
from collections import Counter
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import random
(n, m, k) = inpm()
fi = n * m - (k - 1) * 2
arr = [[0 for i in ra(m)] for j in ra(n)]
(row, col) = (0, 0)
P(fi, end=' ')
turn = True
for i in ra(fi):
	if turn:
		P(row + 1, col % m + 1, end=' ')
		col += 1
		if col % m == 0:
			turn = False
			row += 1
			col = m
	else:
		P(row + 1, col, end=' ')
		col -= 1
		if col == 0:
			turn = True
			row += 1
			col = 0
c = 0
for i in ra(n * m - fi):
	if c % 2 == 0:
		P()
		P(2, end=' ')
	if turn:
		P(row + 1, col % m + 1, end=' ')
		col += 1
		if col % m == 0:
			turn = False
			row += 1
			col = m
	else:
		P(row + 1, col, end=' ')
		col -= 1
		if col == 0:
			turn = True
			row += 1
			col = 0
	c += 1


import time, math, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

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

def IO():
	return stdin.readline()

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

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

def P(x):
	return stdout.write(str(x))

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

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

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count

def solve():
	(n, m, k) = IP()
	li = []
	for i in range(n):
		if i % 2 == 0:
			for j in range(m):
				li.append(i + 1)
				li.append(j + 1)
		else:
			for j in range(m - 1, -1, -1):
				li.append(i + 1)
				li.append(j + 1)
	last = -1
	n = len(li)
	for i in range(k):
		if i == k - 1:
			print((n - last) // 2, end=' ')
			for j in range(last + 1, n):
				print(li[j], end=' ')
		else:
			print(2, end=' ')
			for j in range(last + 1, last + 5):
				print(li[j], end=' ')
			last = last + 4
			print()
solve()


(n, m, k) = map(int, input().split())
a = []
c = True
for i in range(1, n + 1):
	t = [(i, y) for y in range(1, m + 1)]
	if c:
		a.extend(t)
	if not c:
		a.extend(t[::-1])
	c = not c
s = 0
for i in range(0, len(a), len(a) // k):
	s += 1
	if s == k:
		t = a[i:]
		print(len(t), end=' ')
		for (x, y) in t:
			print(x, y, end=' ')
		break
	else:
		t = a[i:i + len(a) // k]
		print(len(t), end=' ')
		for (x, y) in t:
			print(x, y, end=' ')
		print()


(rows, cols, k) = map(int, input().split())
spiralMat = []
left = 0
right = cols - 1
up = 0
down = rows - 1
while left <= right and up <= down:
	for i in range(left, right + 1):
		spiralMat.append((up + 1, i + 1))
	up += 1
	for i in range(up, down + 1):
		spiralMat.append((i + 1, right + 1))
	right -= 1
	if left <= right and up <= down:
		for i in range(right, left - 1, -1):
			spiralMat.append((down + 1, i + 1))
		down -= 1
		for i in range(down, up - 1, -1):
			spiralMat.append((i + 1, left + 1))
		left += 1
n = rows * cols
index = 0
for i in range(k - 1):
	print(2, end=' ')
	for j in range(2):
		print(*spiralMat[index], end=' ')
		index += 1
	print()
print(n - index, end=' ')
for i in range(index, n):
	print(*spiralMat[i], end=' ')
print()


def calcPos(x):
	div = (x - 1) // n + 1
	pos = (x - 1) % n + 1
	if div & 1:
		return (div, pos)
	return (div, n - pos + 1)
(m, n, k) = map(int, input().split())
for i in range(1, k):
	print(2, end=' ')
	pair = calcPos((i << 1) - 1)
	print(*pair, end=' ')
	pair = calcPos(i << 1)
	print(*pair, end='\n')
print(n * m - (k - 1 << 1), end=' ')
i = (k << 1) - 1
while i <= n * m:
	pair = calcPos(i)
	print(*pair, end=' ')
	i = i + 1
print('\n', end='')


(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
l = []
i = 1
j = 1
while i < n + 1:
	if j == 1:
		while j < m + 1:
			l.append((i, j))
			j += 1
		i += 1
	elif j == m + 1:
		j -= 1
		while j > 0:
			l.append((i, j))
			j -= 1
		j += 1
		i += 1
t = n * m
j = 0
c = 0
for i in range(k - 1):
	print(int(t / k), end=' ')
	while j < int(t / k) + c:
		print(l[j][0], l[j][1], end=' ')
		j += 1
	c += int(t / k)
	print('\n', end='')
print(n * m - c, end=' ')
while j < n * m:
	print(l[j][0], l[j][1], end=' ')
	j += 1


(n, m, k) = [int(k) for k in input().split()]
total = n * m
length = [int(total / k)] * (k - 1)
length.append(total - int(total / k) * (k - 1))
table = [[0] * (n + 1) for _ in range(m + 1)]
i = 1
path = []
for r in range(1, m + 1):
	if r % 2 == 0:
		for c in range(n, 0, -1):
			path.append(c)
			path.append(r)
	else:
		for c in range(1, n + 1):
			path.append(c)
			path.append(r)
i = 0
for l in length:
	print(l, end=' ')
	s = ''
	for x in path[i:i + 2 * l]:
		s += str(x) + ' '
	print(s)
	i = i + 2 * l


(n, m, k) = map(int, input().split())
a = n * m
num = 0
for i in range(k - 1):
	print(a // k, end=' ')
	for j in range(a // k):
		if num // m % 2 == 1:
			print(num // m + 1, m - num % m, end=' ')
		else:
			print(num // m + 1, num % m + 1, end=' ')
		num += 1
	print()
print(a - num, end=' ')
while num < a:
	if num // m % 2 == 1:
		print(num // m + 1, m - num % m, end=' ')
	else:
		print(num // m + 1, num % m + 1, end=' ')
	num += 1


def addX(x, y):
	if y % 2 == 0:
		x += 1
		if x == m:
			y += 1
			x -= 1
	else:
		x -= 1
		if x == -1:
			y += 1
			x += 1
	return (x, y)
(n, m, k) = [int(x) for x in input().split()]
res = []
(curx, cury, curk, curlen) = (0, 0, 0, 0)
for i in range(k - 1):
	res.append([])
	for j in range(2):
		res[i].append([cury + 1, curx + 1])
		(curx, cury) = addX(curx, cury)
res.append([])
while cury < n:
	res[k - 1].append([cury + 1, curx + 1])
	(curx, cury) = addX(curx, cury)
print('\n'.join((str(len(x)) + ' ' + ' '.join((' '.join(list(map(str, y))) for y in x)) for x in res)))


(n, m, k) = list(map(int, input().split()))
g = []
rever = 1
for i in range(1, n + 1):
	if rever == 1:
		rever = 0
	else:
		rever = 1
	for j in range(1, m + 1):
		if rever == 0:
			g.append(i)
			g.append(j)
		if rever == 1:
			g.append(i)
			g.append(m + 1 - j)
l = 0
for i in range(k - 1):
	print(2, g[l], g[l + 1], g[l + 2], g[l + 3])
	l += 4
print((len(g) - l) // 2, end=' ')
for i in range(l, len(g)):
	print(g[i], end=' ')


(n, m, k) = [int(x) for x in input().split()]
cells = n * m
(direction, x, y) = (1, 1, 1)
for i in range(k - 1):
	s = '2 '
	for j in range(2):
		s += str(x) + ' ' + str(y)
		y += direction
		cells -= 1
		if j == 0:
			s += ' '
		if not (y <= m and y > 0):
			direction = 1 if direction == -1 else -1
			y += direction
			x += 1
	print(s)
s = str(cells) + ' '
while cells > 0:
	s += str(x) + ' ' + str(y)
	y += direction
	cells -= 1
	if cells > 0:
		s += ' '
	if not (y <= m and y > 0):
		direction = 1 if direction == -1 else -1
		y += direction
		x += 1
print(s)


from sys import stdin, exit, setrecursionlimit
setrecursionlimit(100000000)
from math import *
from bisect import bisect_left
from collections import deque
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
(n, m, k) = mi()
arr = [[] for i in range(k)]
for i in range(1, n + 1):
	if i % 2 == 0:
		for j in range(1, m + 1):
			arr[0].append((i, j))
	else:
		for j in range(m, 0, -1):
			arr[0].append((i, j))
for i in range(1, k):
	arr[i].append(arr[0].pop())
	arr[i].append(arr[0].pop())
for i in arr:
	print(len(i), end=' ')
	for j in i:
		print(str(j[0]) + ' ' + str(j[1]), end=' ')
	print()


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, m, k) = iia()
pos = []
flip = False
for i in range(1, n + 1):
	if not flip:
		for j in range(1, m + 1):
			pos.append([i, j])
		flip = True
	else:
		for j in range(1, m + 1)[::-1]:
			pos.append([i, j])
		flip = False
for i in range(k - 1):
	print(2, *pos.pop(0), *pos.pop(0))
print(len(pos), end=' ')
for i in pos:
	print(i[0], i[1], end=' ')
print()


from itertools import chain
(r, c, n) = map(int, input().split())
ans = []
for i in range(1, r + 1):
	(x, y, z) = (1, c + 1, 1) if i % 2 == 1 else (c, 0, -1)
	for j in range(x, y, z):
		ans.append((i, j))
l = r * c // n
sans = [ans[i:i + l] for i in range(0, (n - 1) * l, l)]
sans.append(ans[l * len(sans):])
print('\n'.join(map(lambda x: ' '.join(map(str, [len(x)] + list(chain(*x)))), sans)))


import sys, math, itertools, random, bisect
from collections import defaultdict
INF = 10 ** 18

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

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

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
test = 1
for _ in range(test):
	(n, m, k) = get_ints()
	path = []
	(x, y, right) = (0, 0, 1)
	path.append([x + 1, y + 1])
	while True:
		y += right
		if y == m:
			right *= -1
			y = m - 1
			x += 1
		if y == -1:
			right *= -1
			y = 0
			x += 1
		if x == n:
			break
		path.append([x + 1, y + 1])
	for i in range(k - 1):
		print(2, *path[2 * i], *path[2 * i + 1])
	rem = m * n - 2 * (k - 1)
	print(rem, end=' ')
	for i in range(2 * (k - 1), len(path)):
		print(*path[i], end=' ')
	print()


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m, k) = map(lambda x: int(x), input().split())
	last = [0, -1]
	direction = 1
	tubes = [[] for i in range(k)]
	for i in range(k - 1):
		if 0 <= last[1] + 2 * direction < m:
			tubes[i].extend([last[0], last[1] + direction, last[0], last[1] + 2 * direction])
			last[1] = last[1] + 2 * direction
			if last[1] == 0 and direction < 0 or (last[1] == m - 1 and direction > 0):
				last = [last[0] + 1, last[1] + direction]
				direction = -direction
		else:
			tubes[i].extend([last[0], last[1] + direction, last[0] + 1, last[1] + direction])
			last = [last[0] + 1, last[1] + direction]
			direction = -direction
	while True:
		if 0 <= last[1] + direction < m:
			tubes[-1].extend([last[0], last[1] + direction])
			last[1] = last[1] + direction
		else:
			tubes[-1].extend([last[0] + 1, last[1]])
			last = [last[0] + 1, last[1]]
			direction = -direction
		if last == [n - 1, 0] and direction < 0 or (last == [n - 1, m - 1] and direction > 0):
			break
	for tube in tubes:
		print(f"{len(tube) // 2} {' '.join(map(lambda x: str(x + 1), tube))}")
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')
input = lambda : sys.stdin.readline().rstrip('\r\n')

def print(*args, **kwargs):
	sep = kwargs.pop('sep', ' ')
	file = kwargs.pop('file', sys.stdout)
	atStart = True
	for x in args:
		if not atStart:
			file.write(sep)
		file.write(str(x))
		atStart = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
main()


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

def walk(n, m):
	for i in range(n):
		if i % 2 == 0:
			for j in range(m):
				yield (i + 1, j + 1)
		else:
			for j in range(m - 1, -1, -1):
				yield (i + 1, j + 1)
w = walk(n, m)
for s in range(k - 1):
	print('2 ', end='')
	print('{} {} '.format(*next(w)), end='')
	print('{} {}'.format(*next(w)), end='')
	print()
r = []
while True:
	try:
		r.append(next(w))
	except StopIteration as e:
		break
print('{} '.format(len(r)), end='')
for i in r:
	print('{} {} '.format(*i), end='')
print()


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

def nex(x, y, s):
	if (y == 1 or y == m) and s:
		return (x + 1, y, False)
	if x % 2:
		return (x, y + 1, True)
	return (x, y - 1, True)
xc = 1
yc = 1
for i in range(k - 1):
	print(2, end=' ')
	print(xc, yc, end=' ')
	(xc, yc, s) = nex(xc, yc, s)
	print(xc, yc)
	(xc, yc, s) = nex(xc, yc, s)
print(n * m - (k - 1) * 2, end=' ')
for i in range(n * m - (k - 1) * 2):
	print(xc, yc, end=' ')
	(xc, yc, s) = nex(xc, yc, s)


(n, m, k) = list(map(int, input().split()))
p = []
for i in range(1, n + 1):
	for j in range(1, m + 1)[::i % 2 * 2 - 1]:
		p.append((i, j))
i = 0
while i < k - 1:
	print(2, p[2 * i][0], p[2 * i][1], p[2 * i + 1][0], p[2 * i + 1][1])
	i += 1
print(len(p) - 2 * i, end=' ')
for j in range(2 * i, len(p)):
	print(p[j][0], p[j][1], end=' ')


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
MOD = pow(10, 9) + 7
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

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')
(n, m, k) = map(int, input().split(' '))
ans = []
for i in range(n):
	for j in range(m):
		if i % 2:
			ans.append((i + 1, m - j))
		else:
			ans.append((i + 1, j + 1))
v = 0
for i in range(k - 1):
	print(2, *ans[2 * i], *ans[2 * i + 1])
	v += 2
print(n * m - v, end=' ')
for i in ans[v:]:
	print(*i, end=' ')


from collections import defaultdict
(n, m, k) = map(int, input().split())
g = []
for i in range(n):
	g.append([0] * m)
d = defaultdict(list)
c = 1
i = 0
j = 0
inc = 1
while i < n:
	if inc == 1:
		if j + 1 < m:
			g[i][j] = c
			g[i][j + 1] = c
			d[c].append(i + 1)
			d[c].append(j + 1)
			d[c].append(i + 1)
			d[c].append(j + 2)
			c = min(c + 1, k)
			j += 2
		elif j == m - 1:
			g[i][j] = c
			d[c].append(i + 1)
			d[c].append(j + 1)
			if i + 1 < n:
				g[i + 1][j] = c
				d[c].append(i + 2)
				d[c].append(j + 1)
				c = min(c + 1, k)
				j = m - 2
			i = i + 1
			inc = -1
		else:
			j = m - 1
			i = i + 1
			inc = -1
	elif j - 1 >= 0:
		g[i][j] = c
		g[i][j - 1] = c
		d[c].append(i + 1)
		d[c].append(j + 1)
		d[c].append(i + 1)
		d[c].append(j)
		c = min(c + 1, k)
		j -= 2
	elif j == 0:
		g[i][j] = c
		d[c].append(i + 1)
		d[c].append(j + 1)
		if i + 1 < n:
			g[i + 1][j] = c
			d[c].append(i + 2)
			d[c].append(j + 1)
			c = min(c + 1, k)
			j = 1
		i = i + 1
		inc = 1
	else:
		j = 0
		inc = 1
		i += 1
	if i == n:
		break
for i in range(1, k + 1):
	print(len(d[i]) // 2, *d[i])


(n, m, k) = input().split(' ')
n = int(n)
m = int(m)
k = int(k)
x1 = n * m // k
x2 = n * m - x1 * (k - 1)
x = 1
y = 1
z = 0
for i in range(0, k - 1):
	print(x1, end=' ')
	for j in range(0, x1):
		if z == 0:
			print(x, y, end=' ')
			y += 1
		else:
			print(x, y, end=' ')
			y -= 1
		if z == 1 and y == 0:
			y = 1
			x += 1
			z = 0
		if z == 0 and y == m + 1:
			y = m
			x += 1
			z = 1
	print()
print(x2, end=' ')
for i in range(0, x2):
	if z == 0:
		print(x, y, end=' ')
		y += 1
	else:
		print(x, y, end=' ')
		y -= 1
	if z == 1 and y == 0:
		y = 1
		x += 1
		z = 0
	if z == 0 and y == m + 1:
		y = m
		x += 1
		z = 1
print()


(n, m, k) = map(int, input().split())
x = 0
last = False
if k == 1:
	print(n * m, end=' ')
	last = True
for i in range(n):
	if i % 2:
		for j in range(m // 2 * 2 - 1, -1, -2):
			if not last:
				x += 1
				print(2, i + 1, j + 1, i + 1, j)
				if x == k - 1:
					print(n * m - (k - 1) * 2, end=' ')
					last = True
			else:
				print(i + 1, j + 1, i + 1, j, end=' ')
	else:
		for j in range(0, m // 2 * 2, 2):
			if not last:
				x += 1
				print(2, i + 1, j + 1, i + 1, j + 2)
				if x == k - 1:
					print(n * m - (k - 1) * 2, end=' ')
					last = True
			else:
				print(i + 1, j + 1, i + 1, j + 2, end=' ')
		if m % 2:
			if not last:
				x += 1
				print(2, i + 1, j + 3, i + 2, j + 3)
				if x == k - 1:
					print(n * m - (k - 1) * 2, end=' ')
					last = True
			elif i + 1 < n:
				print(i + 1, j + 3, i + 2, j + 3, end=' ')
			else:
				print(i + 1, j + 3, end=' ')


__author__ = 'artyom'
(n, m, k) = map(int, input().split())
(i, j, d, t) = (1, 1, 1, 1)
ans = ''

def get_next(x, y, dir):
	y += dir
	if y > m:
		y = m
		x += 1
		dir = -1
	if y == 0:
		y = 1
		x += 1
		dir = 1
	return (x, y, dir)
while t < k:
	ans += '2 ' + str(i) + ' ' + str(j)
	(i, j, d) = get_next(i, j, d)
	ans += ' ' + str(i) + ' ' + str(j) + '\n'
	(i, j, d) = get_next(i, j, d)
	t += 1
rem = n * m - (t - 1) * 2
ans += str(rem)
while rem > 0:
	ans += ' ' + str(i) + ' ' + str(j)
	(i, j, d) = get_next(i, j, d)
	rem -= 1
print(ans)


(m, n, k) = map(int, input().split())
l = n * m // k
sw = 0
ans = []
temp = []
for i in range(n):
	if sw:
		for j in range(m):
			if len(temp) == l and len(ans) != k - 1:
				ans.append(temp)
				temp = []
			temp.append((j + 1, i + 1))
	else:
		for j in range(m - 1, -1, -1):
			if len(temp) == l and len(ans) != k - 1:
				ans.append(temp)
				temp = []
			temp.append((j + 1, i + 1))
	sw ^= 1
ans.append(temp)
for i in ans:
	print(len(i), end=' ')
	st = ''
	for j in i:
		st += str(j[0]) + ' ' + str(j[1]) + ' '
	print(st)


I = lambda : list(map(int, input().split(' ')))
(n, m, k) = I()
lst = []
mat = []
for i in range(1, n + 1):
	t = []
	for j in range(1, m + 1):
		t.append((i, j))
	if i % 2 == 1:
		mat += t
	else:
		mat += t[::-1]

def solve(mat, k):
	ind = 0
	out = []
	while len(out) != k - 1:
		out.append(mat[ind:ind + 2])
		ind += 2
	out.append(mat[ind:])
	for i in range(k):
		print(str(len(out[i])) + ' ' + ' '.join([str(ele[0]) + ' ' + str(ele[1]) for ele in out[i]]))
solve(mat, k)


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
path = []
for i in range(n):
	if i & 1:
		for j in range(m - 1, -1, -1):
			path.append((i + 1, j + 1))
	else:
		for j in range(m):
			path.append((i + 1, j + 1))
taken = 0
ans = []
for i in range(k - 1):
	ans.append(path[taken:taken + 2])
	taken += 2
ans.append(path[taken:])
for sub in ans:
	print(len(sub), end=' ')
	for subsub in sub:
		print(subsub[0], subsub[1], end=' ')
	print()


def snake_pos(m, n):
	for i in range(m * n):
		x = 1 + i // m
		if x % 2 == 1:
			y = i % m + 1
		else:
			y = m - i % m
		yield [x, y]
(n, m, k) = [int(x) for x in input().split(' ')]
g = snake_pos(m, n)
z = n * m - 2 * (k - 1)
ans = [z]
for i in range(z):
	ans.extend(next(g))
print(*ans)
for i in range(k - 1):
	x = [2]
	x.extend(next(g))
	x.extend(next(g))
	print(*x)


import sys
from math import log2, floor, ceil, sqrt, gcd
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

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

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 1000000007
(n, m, k) = Ri()
route = []
d = 1
i = 0
j = 0
while i < n and j < m:
	if d == 1:
		if j + 1 < m:
			route.append([i, j])
			route.append([i, j + 1])
			j += 2
			if j >= m:
				i += 1
				j = m - 1
				d = -1
		else:
			route.append([i, j])
			i += 1
			j = m - 1
			route.append([i, j])
			j -= 1
			d = -1
	elif j - 1 >= 0:
		route.append([i, j])
		route.append([i, j - 1])
		j -= 2
		if j < 0:
			i += 1
			j = 0
			d = 1
	else:
		route.append([i, j])
		i += 1
		j = 0
		route.append([i, j])
		j += 1
		d = 1
	if not (0 <= i < n and 0 <= j < m):
		break
(i, j) = route[-1]
if not (0 <= i < n and 0 <= j < m):
	route.pop()
for i in route:
	i[0] += 1
	i[1] += 1
ite = 0
for i in range(k - 1):
	print('2', end=' ')
	print(*route[ite], end=' ')
	ite += 1
	print(*route[ite], end=' ')
	ite += 1
	print()
print(n * m - (k - 1) * 2, end=' ')
for i in range(ite, len(route)):
	print(*route[i], end=' ')


(n, m, k) = [int(i) for i in input().split()]
arr = []
start = 0
end = m
cont = 1
for i in range(n):
	for j in range(start, end, cont):
		arr.append(i + 1)
		arr.append(j + 1)
	if start == 0:
		start = m - 1
		end = -1
		cont = -1
	else:
		start = 0
		end = m
		cont = 1
start = 0
for i in range(k - 1):
	print(*[2] + arr[start:start + 4])
	start += 4
print(*[n * m - (k - 1) * 2] + arr[start:])


def solve(n, m, k):
	pipes = []
	i = 1
	j = 0
	complete = len(pipes) >= k - 1
	fill_vertical = False
	for i in range(1, n + 1, 2):
		if i >= n:
			fill_vertical = True
			break
		if complete:
			break
		for j in range(1, m + 1):
			if len(pipes) < k - 1:
				pipes.append([(i, j), (i + 1, j)])
			if len(pipes) >= k - 1:
				complete = True
				break
		if complete:
			break
	if not fill_vertical:
		dir_is_left = (m - j) % 2 == 0
		last_pipe = []
		for j_ in range(j + 1, m + 1):
			if dir_is_left:
				last_pipe.extend([(i + 1, j_), (i, j_)])
				dir_is_left = False
			else:
				last_pipe.extend([(i, j_), (i + 1, j_)])
				dir_is_left = True
		is_go_down = False
		for i_ in range(i + 2, n + 1):
			if is_go_down:
				for j_ in range(1, m + 1):
					last_pipe.append((i_, j_))
				is_go_down = False
			else:
				for j_ in range(m, 0, -1):
					last_pipe.append((i_, j_))
				is_go_down = True
		pipes.append(last_pipe)
	if fill_vertical:
		for j in range(1, m + 1, 2):
			if len(pipes) < k - 1:
				pipes.append([(i, j), (i, j + 1)])
			if len(pipes) >= k - 1:
				break
		pipes.append([(i, j_) for j_ in range(j + 2, m + 1)])
	new_pipes = []
	for pipe in pipes:
		cur_pipe = [len(pipe)]
		for (x, y) in pipe:
			cur_pipe.extend([x, y])
		new_pipes.append(cur_pipe)
	return new_pipes
(n, m, k) = map(int, input().split())
for pipe in solve(n, m, k):
	print(' '.join(map(str, pipe)))

def test():
	print(solve(5, 5, 12))


from sys import stdin
import math

def print_special(pcount, i, j):
	if pcount == 0:
		if i == 1 and j == 1:
			print(2, end=' ')
		else:
			print('\n2', end=' ')

def final_param(last_i, last_j, m, n):
	if last_i % 2 == 0:
		if last_j == 1:
			return (last_i + 1, 1)
		else:
			return (last_i, last_j - 1)
	elif last_j == n:
		return (last_i + 1, n)
	else:
		return (last_i, last_j + 1)

def print_initial(m, n, k):
	pcount = 0
	for i in range(1, m + 1):
		if i % 2 == 0:
			for j in range(n, 0, -1):
				if k == 1:
					print()
					return final_param(last_i, last_j, m, n)
				print_special(pcount, i, j)
				(last_i, last_j) = (i, j)
				print(i, j, end=' ')
				pcount += 1
				pcount %= 2
				if pcount == 0:
					k -= 1
		else:
			for j in range(1, n + 1):
				if k == 1:
					print()
					return final_param(last_i, last_j, m, n)
				print_special(pcount, i, j)
				(last_i, last_j) = (i, j)
				print(i, j, end=' ')
				pcount += 1
				pcount %= 2
				if pcount == 0:
					k -= 1

def print_final(last_i, last_j, m, n):
	print(m * n - 2 * (k - 1), end=' ')
	if last_i % 2 == 0:
		for j in range(last_j, 0, -1):
			print(last_i, j, end=' ')
	else:
		for j in range(last_j, n + 1):
			print(last_i, j, end=' ')
	for i in range(last_i + 1, m + 1):
		if i % 2 == 0:
			for j in range(n, 0, -1):
				print(i, j, end=' ')
		else:
			for j in range(1, n + 1):
				print(i, j, end=' ')
(m, n, k) = list(map(int, stdin.readline().split()))
last_i = 1
last_j = 1
if k > 1:
	(last_i, last_j) = print_initial(m, n, k)
print_final(last_i, last_j, m, n)


def nex(x, y):
	if x % 2 == 1:
		if y == m:
			return (x + 1, y)
		else:
			return (x, y + 1)
	elif y == 1:
		return (x + 1, y)
	else:
		return (x, y - 1)
(n, m, k) = map(int, input().split())
ans = []
(x, y) = (1, 1)
for i in range(k):
	if i < k - 1:
		c = 2
	else:
		c = n * m - 2 * (k - 1)
	ans_i = [c]
	for _ in range(c):
		ans_i.append(x)
		ans_i.append(y)
		(x, y) = nex(x, y)
	ans.append(ans_i)
for ans_i in ans:
	print(*ans_i)


def next(x, y, xx):
	if x == n and xx == 1:
		y += 1
		xx *= -1
	elif x == 1 and xx == -1:
		y += 1
		xx *= -1
	else:
		x += xx
	return (x, y, xx)
(n, m, num) = map(int, input().split(' '))
x = 1
xx = -1
y = 0
for i in range(num - 1):
	j = 0
	s = '2 '
	while j < 2:
		(x, y, xx) = next(x, y, xx)
		s += '{} {} '.format(str(x), str(y))
		j += 1
	print(s)
s = str(n * m - 2 * (num - 1)) + ' '
for i in range(n * m - 2 * (num - 1)):
	(x, y, xx) = next(x, y, xx)
	s += '{} {} '.format(str(x), str(y))
print(s)


(n, m, k) = map(int, input().split(' '))
ans = []
temp = []
chk = 1
k -= 1
for x in range(n):
	if chk == 1:
		for y in range(m):
			if len(temp) == 0:
				temp.append(x + 1)
				temp.append(y + 1)
			elif k <= 0:
				temp.append(x + 1)
				temp.append(y + 1)
			else:
				k -= 1
				temp.append(x + 1)
				temp.append(y + 1)
				ans.append(temp)
				temp = []
		chk ^= 1
	elif chk == 0:
		for y in range(m - 1, -1, -1):
			if len(temp) == 0:
				temp.append(x + 1)
				temp.append(y + 1)
			elif k <= 0:
				temp.append(x + 1)
				temp.append(y + 1)
			else:
				k -= 1
				temp.append(x + 1)
				temp.append(y + 1)
				ans.append(temp)
				temp = []
		chk ^= 1
ans.append(temp)
for x in ans:
	print(len(x) // 2, end=' ')
	print(*x)


(n, m, k) = map(int, input().split())
x = 1
y = 1
add = 1
for pNum in range(k - 1):
	print(2, end=' ')
	print(x, y, end=' ')
	y += add
	if y == m + 1:
		y = m
		add = -1
		x = x + 1
	if y == 0:
		y = 1
		add = 1
		x = x + 1
	print(x, y, end=' ')
	y += add
	if y == m + 1:
		y = m
		add = -1
		x = x + 1
	if y == 0:
		y = 1
		add = 1
		x = x + 1
	print()
print(n * m - 2 * (k - 1), end=' ')
while x < n + 1:
	print(x, y, end=' ')
	y += add
	if y == m + 1:
		y = m
		add = -1
		x = x + 1
	if y == 0:
		y = 1
		add = 1
		x = x + 1
print()


arr = [int(x) for x in input().split()]
n = arr[0]
m = arr[1]
k = arr[2]
arr = [[1 for j in range(m)] for i in range(n)]
row = 1
col = 1
c = 0
ans = []
(l1, l2, l3, l4) = ([1, m], [1, n], [m, 1], [n, 1])
while c < n * m:
	for i in range(l1[0], l1[1] + 1):
		c += 1
		ans.append([l4[1], i])
	l2[0] += 1
	l4[1] += 1
	if c == n * m:
		break
	for i in range(l2[0], l2[1] + 1):
		c += 1
		ans.append([i, l1[1]])
	l1[1] -= 1
	l3[0] -= 1
	if c == n * m:
		break
	for i in range(l3[0], l3[1] - 1, -1):
		c += 1
		ans.append([l2[1], i])
	l2[1] -= 1
	l4[0] -= 1
	if c == n * m:
		break
	for i in range(l4[0], l4[1] - 1, -1):
		c += 1
		ans.append([i, l3[1]])
	l3[1] += 1
	l1[0] += 1
	if c == n * m:
		break
k -= 1
i = 0
while k > 0:
	print(2, ans[i][0], ans[i][1], ans[i + 1][0], ans[i + 1][1])
	i += 2
	k -= 1
ans = ans[i:]
print(len(ans), end=' ')
for ele in ans:
	print(ele[0], ele[1], end=' ')


(m, n, k) = map(int, input().split())
(i, l, q, w, t) = (n * m, [], 1, 1, 0)
while i > 0:
	l += [q, w]
	i -= 1
	if i == 0:
		break
	if w == n or (w == 1 and t):
		q += 1
		l += [q, w]
		t = 1 - t
		i -= 1
	w += (-1) ** t
for i in range(0, 4 * k - 4, 4):
	print(*[2] + l[i:i + 4])
print(*[n * m - 2 * k + 2] + l[k * 4 - 4:])


(n, m, k) = map(int, input().split())
c = []
r = [2] * (k - 1) + [n * m - 2 * (k - 1)]
no = 0
f = 1
x = 1
y = 1
for i in range(1, k):
	c.append([])
	for j in range(2):
		if y > m:
			f = -1
			y = m
			x += 1
		if y < 1:
			y = 1
			f = 1
			x += 1
		c[no] += [(x, y)]
		y += f
	no += 1
c.append([])
for j in range(r[-1]):
	if y > m:
		f = -1
		y = m
		x += 1
	if y < 1:
		y = 1
		f = 1
		x += 1
	c[no] += [(x, y)]
	y += f
for i in range(k):
	print(r[i], end=' ')
	for (x, y) in c[i]:
		print(x, y, end=' ')
	print()


import sys
import math as mt
mod = 1000000007
t = 1
for __ in range(t):
	(n, m, k) = map(int, input().split())
	(x, y) = (1, 0)
	d = 0
	r = 1
	ch = 1
	cnt1 = 1
	for i in range(k - 1):
		print(2, end=' ')
		for j in range(2):
			if y + 1 <= m and mt.ceil(cnt1 / m) % 2 != 0 and (ch == 1):
				y += 1
				if y == m:
					ch = 0
				print(x, y, end=' ')
			elif ch == 0:
				x += 1
				ch = 1
				print(x, y, end=' ')
			else:
				y -= 1
				if y == 1:
					ch = 0
				print(x, y, end=' ')
			cnt1 += 1
		print()
	if n * m - 2 * (k - 1) > 0:
		print(n * m - 2 * (k - 1), end=' ')
		cnt = n * m - 2 * (k - 1)
		while cnt > 0:
			if y + 1 <= m and mt.ceil(cnt1 / m) % 2 != 0 and (ch == 1):
				y += 1
				if y == m:
					ch = 0
				print(x, y, end=' ')
			elif ch == 0:
				ch = 1
				x += 1
				print(x, y, end=' ')
			else:
				y -= 1
				if y == 1:
					ch = 0
				print(x, y, end=' ')
			cnt -= 1
			cnt1 += 1


(n, m, k) = map(int, input().split())
x = 1
y = 1
inc = 1
tot = 0

def check(x, y, inc):
	if y < 1:
		return [x + 1, 1, 1]
	elif y > m:
		return [x + 1, m, -1]
	else:
		return [x, y, inc]
while k != 1:
	print(2, end=' ')
	l = check(x, y + inc, inc)
	x1 = l[0]
	y1 = l[1]
	inc = l[2]
	print(x, y, x1, y1)
	l = check(x1, y1 + inc, inc)
	x = l[0]
	y = l[1]
	inc = l[2]
	k -= 1
	tot += 2
if n * m - tot > 0:
	print(n * m - tot, end=' ')
	while x <= n:
		print(x, y, end=' ')
		l = check(x, y + inc, inc)
		x = l[0]
		y = l[1]
		inc = l[2]


(n, m, k) = map(int, input().split())
x = []
y = []
for i in range(n):
	if i % 2 == 0:
		for j in range(m):
			x.append(i + 1)
			y.append(j + 1)
	else:
		for j in range(m - 1, -1, -1):
			x.append(i + 1)
			y.append(j + 1)
j = 0
p = n * m
for i in range(k - 1):
	p1 = str(x[j]) + ' ' + str(y[j])
	j += 1
	p2 = str(x[j]) + ' ' + str(y[j])
	j += 1
	p -= 2
	print('2', p1, p2)
l = []
for i in range(j, len(x)):
	l.append(x[i])
	l.append(y[i])
s = str()
for i in l:
	s += str(i) + ' '
print(p, s)


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

def nxtLoc(r, c):
	if c == m - 1 and r % 2 == 0 or (c == 0 and r % 2):
		return (r + 1, c)
	return (r, c + 1) if r % 2 == 0 else (r, c - 1)
loc = (0, -1)
for t in range(k):
	if t < k - 1:
		print(2, end=' ')
		for i in range(2):
			loc = nxtLoc(loc[0], loc[1])
			print(loc[0] + 1, loc[1] + 1, end=' ')
		print()
	else:
		rem = n * m - 2 * (k - 1)
		print(rem, end=' ')
		for i in range(rem):
			loc = nxtLoc(loc[0], loc[1])
			print(loc[0] + 1, loc[1] + 1, end=' ')
		print()


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n, m, k) = list(map(int, input().split()))
pipes = [[]]
for i in range(1, n + 1):
	for j in range(1, m + 1)[::i % 2 * 2 - 1]:
		if len(pipes) < k and len(pipes[-1]) >= 2:
			pipes.append([])
		pipes[-1].append((i, j))
for pipe in pipes:
	print(len(pipe), end=' ')
	for x in pipe:
		print(x[0], x[1], end=' ')
	print('')


(n, m, k) = [int(x) for x in input().split()]
l = []
for i in range(n):
	if i % 2 == 0:
		for j in range(m):
			l.append(i + 1)
			l.append(j + 1)
	else:
		for j in range(m - 1, -1, -1):
			l.append(i + 1)
			l.append(j + 1)
ans = []
x = 0
for i in range(k - 1):
	ans.append(l[x:x + 4])
	x += 4
ans.append(l[x:])
for i in ans:
	print(len(i) // 2, end=' ')
	print(*i)


(n, m, k) = list(map(int, input().split()))
ans = []
(x, y) = (1, 0)
while k > 1:
	temp = []
	cnt = 2
	if x % 2 != 0:
		if y + 1 <= m:
			temp.append([x, y + 1])
			y += 1
			cnt -= 1
		else:
			x += 1
			temp.append([x, y])
			cnt -= 1
		if x % 2 != 0:
			if y + 1 <= m:
				temp.append([x, y + 1])
				y += 1
				cnt -= 1
			else:
				x += 1
				temp.append([x, y])
				cnt -= 1
		elif y - 1 > 0:
			y -= 1
			temp.append([x, y])
		else:
			x += 1
			temp.append([x, y])
	else:
		if y - 1 > 0:
			y -= 1
			temp.append([x, y])
		else:
			x += 1
			temp.append([x, y])
		if x % 2 != 0:
			if y + 1 <= m:
				temp.append([x, y + 1])
				y += 1
				cnt -= 1
			else:
				x += 1
				temp.append([x, y])
				cnt -= 1
		elif y - 1 > 0:
			y -= 1
			temp.append([x, y])
		else:
			x += 1
			temp.append([x, y])
	k -= 1
	ans.append(temp)
temp = []
for i in range(x, n + 1):
	if i % 2 != 0:
		for j in range(y + 1, m + 1):
			temp.append([i, j])
		y = m + 1
	else:
		for j in range(y - 1, 0, -1):
			temp.append([i, j])
		y = 0
ans.append(temp)
for i in ans:
	print(len(i), end=' ')
	for j in i:
		print(*j, end=' ')
	print()


(n, m, k) = map(int, input().split())
ans = []
f = 1
for i in range(1, n + 1):
	if f:
		for j in range(1, m + 1):
			ans.append((str(i), str(j)))
		f = 0
	else:
		for j in range(m, 0, -1):
			ans.append((str(i), str(j)))
		f = 1
for i in range(k - 1):
	print(str(2), ' '.join(ans.pop()), ' '.join(ans.pop()))
print(len(ans), end=' ')
for i in ans:
	print(i[0], i[1], end=' ')
print()


def generateNext(i, j, c):
	if i % 2 == 1:
		if j == c:
			return [i + 1, j]
		else:
			return [i, j + 1]
	elif j == 1:
		return [i + 1, j]
	else:
		return [i, j - 1]

def main():
	(r, c, k) = list(map(int, input().split()))
	left = r * c
	i = 1
	j = 1
	while k > 0:
		if k != 1:
			print(2, end=' ')
			print(i, j, end=' ')
			(i, j) = generateNext(i, j, c)
			print(i, j, end=' ')
			(i, j) = generateNext(i, j, c)
			left = left - 2
		else:
			print(left, end=' ')
			while left > 0:
				print(i, j, end=' ')
				(i, j) = generateNext(i, j, c)
				left = left - 1
		print('')
		k = k - 1
main()


(n, m, k) = map(int, input().split())
ans = []
curr = 1
now = [1, 1]
tr = []
tr.append(now)
z = n * m
while z:
	z -= 1
	x = now[0]
	y = now[1]
	if curr == 1:
		if y + 1 > m:
			x += 1
			curr = -1
		else:
			x += 0
			y += 1
		now = [x, y]
	else:
		if y == 1:
			x += 1
			curr = 1
		else:
			x += 0
			y -= 1
		now = [x, y]
	tr.append(now)
le = n * m
j = 0
ans = tr[:]
sm = 0
while k > 1:
	print(2, ans[j][0], ans[j][1], ans[j + 1][0], ans[j + 1][1])
	k -= 1
	j += 2
	sm += 2
rem = n * m - sm
print(rem, end=' ')
for k in range(j, n * m):
	print(ans[k][0], ans[k][1], end=' ')


(n, m, k) = map(int, input().split())
l = 1
r = 1
c = 0
k1 = k
rev = False
for i in range(n):
	for j in range(m):
		if k > 1:
			if c == 0:
				print(2, end=' ')
			if rev == False:
				print(i + 1, j + 1, end=' ')
			else:
				print(i + 1, m - j, end=' ')
			c += 1
			if c == 2:
				print()
				c = 0
				k -= 1
		else:
			if c == 0:
				print(n * m - (k1 - 1) * 2, end=' ')
				c += 1
			if rev == False:
				print(i + 1, j + 1, end=' ')
			else:
				print(i + 1, m - j, end=' ')
	rev = not rev


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

def next_cell(x, y):
	if x % 2 == 1 and y < m:
		return [x, y + 1]
	elif x % 2 == 0 and y > 1:
		return [x, y - 1]
	else:
		return [x + 1, y]
for i in range(1, k):
	(x2, y2) = next_cell(x, y)
	print(2, x, y, x2, y2)
	(x, y) = next_cell(x2, y2)
last = [x, y]
req_len = n * m - (k - 1) * 2
while len(last) < req_len * 2:
	(x, y) = next_cell(x, y)
	last.append(x)
	last.append(y)
print(len(last) // 2, ' '.join(map(str, last)))


(n, m, k) = [int(i) for i in input().split()]
x = 1
y = 1
arr = [[1, 1]]
inv = 1
z = n * m
while z > 1:
	z -= 1
	if y < m and inv == 1:
		y += 1
	elif y > 1 and inv == -1:
		y -= 1
	else:
		x += 1
		inv = -inv
	arr.append([x, y])
z = n * m
tLen = z // k
pipes = 0
while pipes < k and z > 0:
	if pipes != k - 1:
		temp = tLen
	else:
		temp = z
	print(temp, end=' ')
	for _ in arr[:temp]:
		print(*arr.pop(), end=' ')
	print()
	z -= temp
	pipes += 1


import sys, os, io

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

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

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

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

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
sys.setrecursionlimit(111111)
INF = 99999999999999999999999999999999

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(n, m, k) = ria()
		matrix = [[0] * m for i in range(n)]
		t = 0
		p = 0
		c = 1
		a = deque([])
		for i in range(n):
			t = 1 - t
			if t:
				for j in range(m):
					p += 1
					a.append([i + 1, j + 1])
					matrix[i][j] = c
					if p % 2 == 0:
						if c + 1 > k:
							c = k
						else:
							c += 1
			else:
				for j in range(m - 1, -1, -1):
					p += 1
					a.append([i + 1, j + 1])
					matrix[i][j] = c
					if p % 2 == 0:
						if c + 1 > k:
							c = k
						else:
							c += 1
		for i in range(1, k):
			ans = [2]
			(x, y) = a.popleft()
			ans += [x, y]
			(x, y) = a.popleft()
			ans += [x, y]
			wia(ans)
		ans = [len(a)]
		for i in range(len(a)):
			(x, y) = a.popleft()
			ans += [x, y]
		wia(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

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

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

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

class FastWriter(io.IOBase):

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

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

class FastStdin(io.IOBase):

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

class FastStdout(io.IOBase):

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


from sys import stdin, stdout
(n, m, k) = map(int, stdin.readline().split())
rt = []
for i in range(1, n + 1):
	lt = []
	if i % 2 == 1:
		for j in range(1, m + 1):
			lt.extend([i, j])
	else:
		for j in range(m, 0, -1):
			lt.extend([i, j])
	rt.extend(lt)
ans = []
p = 0
for i in range(0, 4 * k - 7, 4):
	ans.append(rt[i:i + 4])
	p = i + 4
ans.append(rt[p:])
for x in ans:
	print(len(x) // 2, *x)


(n, m, k) = map(int, input().split())
last_block_size = m * n - 2 * (k - 1)
val = 1
table = dict()
for i in range(1, n + 1):
	if i % 2:
		for j in range(1, m + 1):
			table[val] = (i, j)
			val += 1
	else:
		for j in range(m, 0, -1):
			table[val] = (i, j)
			val += 1
val = 1
for _ in range(1, k):
	print(2, end=' ')
	for i in range(2):
		for coord in table[val]:
			print(coord, end=' ')
		val += 1
	print('')
print(last_block_size, end=' ')
while val <= m * n:
	for coord in table[val]:
		print(coord, end=' ')
	val += 1


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')
from collections import Counter
import math
from math import inf
import bisect
(n, m, k) = map(int, input().split())
t = n * m // k
x = 1
y = 1
f = 0
ran = k
ex = n * m % k
for i in range(k):
	if ex > 0:
		ran = t + 1
		ex -= 1
	else:
		ran = t
	print(ran, end=' ')
	for i in range(ran):
		print(*[x, y], end=' ')
		if f == 0:
			y += 1
		else:
			y -= 1
		if y > m:
			f = 1
			y = m
			x += 1
		if y < 1:
			y = 1
			x += 1
			f = 0
	print()


(n, m, k) = map(int, input().split())
c = k
dir = 'right'
start_x = 1
start_y = 1
ans = []
while c > 0:
	if c == 1:
		r = m * n - 2 * (k - 1)
		s = str(r) + ' '
		pos = []
		while r > 0:
			pos.append((start_y, start_x))
			move = 1 if dir == 'right' else -1
			start_x += move
			if start_x == m + 1:
				start_x = m
				start_y += 1
				dir = 'left'
			if start_x == 0:
				start_x = 1
				start_y += 1
				dir = 'right'
			r -= 1
		s += ' '.join(['{} {}'.format(x[0], x[1]) for x in pos])
		ans.append(s)
	else:
		move = 2 if dir == 'right' else -2
		if dir == 'right':
			if start_x + move > m + 1:
				ans.append('2 {} {} {} {}'.format(start_y, start_x, start_y + 1, start_x))
				start_x = m
				start_y += 1
				move -= 1
				dir = 'left'
				start_x -= 1
			else:
				ans.append('2 {} {} {} {}'.format(start_y, start_x, start_y, start_x + 1))
				start_x += 2
				if start_x > m:
					start_y += 1
					start_x = m
					dir = 'left'
		elif start_x + move < 0:
			ans.append('2 {} {} {} {}'.format(start_y, start_x, start_y + 1, start_x))
			start_x = 1
			start_y += 1
			move -= 1
			dir = 'right'
			start_x += 1
		else:
			ans.append('2 {} {} {} {}'.format(start_y, start_x, start_y, start_x - 1))
			start_x -= 2
			if start_x < 1:
				start_y += 1
				start_x = 1
				dir = 'right'
	c -= 1
print(*ans, sep='\n')


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

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

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

def insr():
	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')
(n, m, k) = invr()
d = []
for i in range(1, n + 1):
	if i % 2 != 0:
		for j in range(1, m + 1):
			d.append(i)
			d.append(j)
	else:
		for j in range(m, 0, -1):
			d.append(i)
			d.append(j)
r = 0
for i in range(k - 1):
	print(2, d[r], d[r + 1], d[r + 2], d[r + 3])
	r += 4
print((len(d) - r) // 2, *d[r:])