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