#include <bits/stdc++.h>
using namespace std;
int N, M, K, A[1100 + 1][1100 + 1];
int main(void) {
  scanf("%d%d%d", &N, &M, &K);
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      scanf("%d", &A[i][j]);
    }
  }
  printf("%d\n", M * (M - 1) / 2);
  for (int i = 1; i <= M; i++) {
    for (int j = i + 1; j <= M; j++) {
      if (K == 0)
        printf("%d %d\n", i, j);
      else
        printf("%d %d\n", j, i);
    }
  }
  return 0;
}
