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