#include <bits/stdc++.h>
using namespace std;
long long i, n, m, k, h, a[100001], s, j, c[101], t[101], l = 0;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (i = 1; i <= n * m; i++) cin >> a[i];
  cout << (m * (m - 1)) / 2 << endl;
  if (k == 0) {
    for (i = 1; i < m; i++) {
      for (j = i + 1; j <= m; j++) cout << i << " " << j << endl;
    }
  } else {
    for (i = 1; i < m; i++) {
      for (j = i + 1; j <= m; j++) cout << j << " " << i << endl;
    }
  }
  return 0;
}
