Iahub wants to enhance his multitasking abilities. In order to do this, he wants to sort *n* arrays simultaneously, each array consisting of *m* integers.

Iahub can choose a pair of distinct indices *i* and *j* (1 ≤ *i*, *j* ≤ *m*, *i* ≠ *j*). Then in each array the values at positions *i* and *j* are swapped only if the value at position *i* is strictly greater than the value at position *j*.

Iahub wants to find an array of pairs of distinct indices that, chosen in order, sort all of the *n* arrays in ascending or descending order (the particular order is given in input). The size of the array can be at most <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/6f1b5d2dbdd1c5069f06964cc691c24429c6151c.png" style="max-width: 100.0%;max-height: 100.0%;"/> (at most <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/6f1b5d2dbdd1c5069f06964cc691c24429c6151c.png" style="max-width: 100.0%;max-height: 100.0%;"/> pairs). Help Iahub, find any suitable array.
The first line contains three integers *n* (1 ≤  *n* ≤ 1000), *m* (1 ≤ *m* ≤  100) and *k*. Integer *k* is 0 if the arrays must be sorted in ascending order, and 1 if the arrays must be sorted in descending order. Each line *i* of the next *n* lines contains *m* integers separated by a space, representing the *i*-th array. For each element *x* of the array *i*, 1 ≤ *x* ≤ 10<sup class="upper-index">6</sup> holds.
from sys import stdin, setrecursionlimit, stdout
from itertools import permutations
#setrecursionlimit(1000000) #use "python" instead of "pypy" to avoid MLE
from io import BytesIO
import os
from functools import cmp_to_key
from collections import deque, Counter, defaultdict, OrderedDict
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
from heapq import heapify, heappop, heappush, heapreplace, heappushpop
#	to use maxheap, invert all the number.. that means, multyply with -1
from bisect import bisect_right, bisect_left
#	number of elements in a range is bisect_right(a, el)-bisect_left(a, el)
from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, hexdigits, whitespace, punctuation


def ii(): return int(input().decode()) if not DEBUG else int(input())


def fi(): return float(input().decode()) if not DEBUG else float(input())


def mi(): return map(int, input().decode().split()) if not DEBUG else map(int, input().split())


def fmi(): return map(float, input().decode().split()) if not DEBUG else map(float, input().split())


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


def si(): return input().decode().rstrip() if not DEBUG else input().rstrip()


def msi(): return map(str, input().decode().split()) if not DEBUG else map(str, input().split())


def lsi(): return list(si())


#######################################################################################
###########################    M Y     F U N C T I O N S    ###########################
#######################################################################################






#######################################################################################
###########################    M A I N     P R O G R A M    ###########################
#######################################################################################

def main():
	n, m, t=mi()
	for _ in range(n):
		li()
	res=[]
	for i in range(1, m+1):
		for j in range(i+1, m+1):
			res.append([i, j])
	print(len(res))
	if not t:
		for i in res:
			print(*i)
	else:
		for i in res:
			print(i[1], i[0])















#######################################################################################
###########################    S T A R T E R     P A C K    ###########################
#######################################################################################

if __name__ == "__main__":
	DEBUG = os.environ.get("__DEBUG__")

	if DEBUG:
		if os.stat("input.txt").st_size == 0:
			input = stdin.readline
		else:
			input = open('input.txt', 'r').readline
	else:
		input = BytesIO(os.read(0, os.fstat(0).st_size)).readline

	vow = {'A', 'E', 'I', 'O', 'U'}
	mod = 1000000007

	mod1 = 100000110709
	mod2 = 100000110719
	res = ['NO', 'YES']
	adj4 = [[-1, 0], [0, -1], [0, 1], [1, 0]]
	adj8 = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]

	test, test_case = 0, 1
	#test_case = int(input())

	while test < test_case:
		test += 1
		if DEBUG:
			print('>>>>>>>>>>>>> Case #{} >>>>>>>>>>>>>'.format(test))
			pass
		#print('Case ', test, ': ', sep='', end='')
		main()
 		     		 		 		 	 		    	 	 	