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