#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
const int N = 1e5 + 7, M = 53;
int mat[1009][1009], row[1009], col[1009];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mat[i][j];
    }
  }
  cout << m * (m - 1) / 2 << endl;
  if (!k) {
    for (int i = 0; i < m - 1; i++) {
      for (int j = i + 1; j < m; j++) {
        cout << i + 1 << " " << j + 1 << endl;
      }
    }
  } else {
    for (int i = 0; i < m - 1; i++) {
      for (int j = i + 1; j < m; j++) {
        cout << j + 1 << " " << i + 1 << endl;
      }
    }
  }
}
