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