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