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