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