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