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