#include <bits/stdc++.h>
using namespace std;
long a;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int j = 1; j <= n; j++)
    for (int i = 1; i <= m; i++) cin >> a;
  cout << m * (m - 1) / 2 << endl;
  if (k == 1) {
    for (int i = 1; i <= (m - 1); i++)
      for (int j = (i + 1); j <= m; j++) cout << j << " " << i << endl;
  } else {
    for (int i = m; i >= 2; i--)
      for (int j = (i - 1); j >= 1; j--) cout << j << " " << i << endl;
  }
  return 0;
}
