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