#include <bits/stdc++.h>
using namespace std;
int main() {
  int A;
  int n, m;
  cin >> n >> m;
  int k;
  cin >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A;
    }
  }
  vector<pair<int, int> > res;
  for (int i = m - 1; i >= 1; i--) {
    for (int j = m - 1; j >= m - i; j--) {
      if (k == 0) {
        res.push_back(make_pair(j, j + 1));
      } else {
        res.push_back(make_pair(j + 1, j));
      }
    }
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++) {
    cout << res[i].first << " " << res[i].second << endl;
  }
  return 0;
}
