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