#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1.01e9;
const long double EPS = 1e-9;
void precalc() {}
const int maxn = (int)1e3 + 10, maxm = (int)1e2 + 10;
int a[maxn][maxm];
int n, m, k;
bool read() {
  if (scanf("%d%d%d", &n, &m, &k) < 3) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  return 1;
}
void solve() {
  printf("%d\n", m * (m - 1) / 2);
  for (int i = 0; i < m; ++i) {
    for (int j = i + 1; j < m; ++j) {
      printf("%d %d\n", 1 + (k ? (m - 1 - i) : i), 1 + (k ? (m - 1 - j) : j));
    }
  }
}
int main() {
  srand(rdtsc());
  precalc();
  while (1) {
    if (!read()) {
      break;
    }
    solve();
  }
  return 0;
}
