#include <bits/stdc++.h>
using namespace std;
int const N = 1e6 + 1;
int n, m, k;
vector<int> g[N];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    for (int j = 0, x; j < m; ++j) {
      scanf("%d", &x);
      g[i].push_back(x);
    }
  }
  printf("%d\n", (m * (m - 1)) / 2);
  if (!k) {
    for (int i = 1; i <= m; ++i) {
      for (int j = i + 1; j <= m; ++j) {
        cout << i << " " << j << "\n";
      }
    }
  } else {
    for (int i = m; i >= 1; --i) {
      for (int j = i - 1; j >= 1; --j) {
        cout << i << " " << j << "\n";
      }
    }
  }
}
