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.
#define ll long long
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <bits/stdc++.h>
#include <map>
using namespace std;



int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> a(n, vector<int>(m));
    set<pair<int, int>> sol;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m - 1; i++) {
        for (int j = i + 1; j < m; j++) {
            if (k == 0) {
                for (int x = 0; x < n; x++) {
                    if (a[x][i] > a[x][j]) {
                        int temp = a[x][i];
                        a[x][i] = a[x][j];
                        a[x][j] = temp;
                        sol.insert(make_pair(i, j));
                    }
                }

            }else {
                for (int x = 0; x < n; x++) {
                    if (a[x][i] < a[x][j]) {
                        int temp = a[x][i];
                        a[x][i] = a[x][j];
                        a[x][j] = temp;
                        sol.insert(make_pair(i, j));
                    }
                }
            }
        }
    }

    for (auto p : sol) {
        cout << p.first + 1 << " " << p.second + 1 << endl;
    }

    //for (int i = 0; i < n; i++) {
    //    for (int j = 0; j < m; j++) {
    //        cout << a[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    return 0;
}
