#include <bits/stdc++.h>
using namespace std;
int a[1009][109], n, m, i, k, j;
int main() {
  cin >> n >> m >> k;
  for (i = 1; n >= i; i++)
    for (j = 1; m >= j; j++) cin >> a[i][j];
  cout << m * (m - 1) / 2 << endl;
  for (i = 1; m >= i; i++)
    for (j = i + 1; m >= j; j++)
      !k ? cout << i << " " << j << endl : cout << j << " " << i << endl;
}
