#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int tot = m * (m - 1) / 2;
  printf("%d\n", tot);
  for (int i = 1; i <= m; ++i)
    for (int j = i + 1; j <= m; ++j) {
      if (k) {
        printf("%d %d\n", j, i);
      } else {
        printf("%d %d\n", i, j);
      }
    }
}
