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.
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from sys import stdin, stdout
import io
import math
import heapq
import bisect
import collections
import copy
import collections, sys, threading
def ceil(a, b):
    return (a + b - 1) // b
inf = float('inf')
def get():
    return stdin.readline().rstrip()
mod = 10 ** 9 + 7
import collections, sys, threading
sys.setrecursionlimit(1500)
# for _ in range(int(get())):
# n=int(get())
#l=list(map(int,get().split()))
# = map(int,get().split())
def decimalToBinary(n):
    return bin(n).replace("0b", "")
##################################################
n,m,k= map(int,get().split())
l=[]
for i in range(n):
    l1=list(map(int,get().split()))
    l.append(l1)
if k==0:
    for i in range(1,m+1):
        for j in range(i+1,m+1):
            print(i,j)
else:
    print((n*(n-1))//2)
    for i in range(m,0,-1):
        for j in range(i-1,0,-1):
            print(i,j)





