#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, k, temp;
  ;
  scanf("%lld", &n);
  scanf("%lld", &m);
  scanf("%lld", &k);
  long long ct = n * m;
  printf("%lld\n", (m * (m - 1)) / 2);
  for (long long i = 2; i < m + 1; i++) {
    long long ic = i;
    while (ic != 1) {
      if (k)
        printf("%lld %lld\n", ic, ic - 1);
      else
        printf("%lld %lld\n", ic - 1, ic);
      ic--;
    }
  }
  return 0;
}
