#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> x;
  int m1 = m * (m - 1) / 2;
  int a[m1];
  int b[m1];
  int k1 = 0;
  for (int i = 1; i <= m; i++)
    for (int j = i + 1; j <= m; j++) {
      a[k1] = i;
      b[k1] = j;
      k1++;
    }
  cout << m1 << endl;
  if (k == 0) {
    for (int i = 0; i < m1; i++) cout << a[i] << " " << b[i] << endl;
  } else {
    for (int i = 0; i < m1; i++) cout << b[i] << " " << a[i] << endl;
  }
  return 0;
}
