#include <bits/stdc++.h>
using namespace std;
int ans1[10010], ans2[10010];
int n, m, order;
int cnt[110][110];
int a[1010][110];
int ans;
int main() {
  scanf("%d%d%d", &n, &m, &order);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; 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 (!order) {
        printf("%d %d\n", i, j);
      } else
        printf("%d %d\n", j, i);
    }
  }
  return 0;
}
