#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) { return a > b ? a : b; }
bool r(long long a, long long b) { return a > b; }
long long min(long long a, long long b) { return a < b ? a : b; }
long long mindist(char a, char b) {
  if (a > b) swap(a, b);
  return min(b - a, (a - 'A') + ('Z' - b) + 1);
}
void solve() {
  long long n, m, o;
  cin >> n >> m >> o;
  vector<vector<long long> > v;
  for (long long i = 0; i < n; i++) {
    vector<long long> x(m);
    for (int j = 0; j < m; j++) cin >> x[j];
    v.push_back(x);
  }
  if (o == 0) {
    cout << (m * (m - 1)) / 2 << '\n';
    for (int i = 1; i <= m; i++) {
      for (int j = i + 1; j <= m; j++) {
        cout << i << " " << j << '\n';
      }
    }
  } else {
    cout << (m * (m - 1)) / 2 << '\n';
    for (int i = m; i >= 1; i--) {
      for (int j = i - 1; j >= 1; j--) cout << i << " " << j << '\n';
    }
  }
}
int main() {
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
