#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1677777216")
using namespace std;
struct point {
  long long l, c, seg;
};
int a[1234];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[j];
  cout << m * (m - 1) / 2 << endl;
  if (k == 0) {
    for (int i = 1; i <= m; i++)
      for (int j = i + 1; j <= m; j++) cout << i << " " << j << endl;
  } else {
    for (int i = m; i >= 1; i--)
      for (int j = i - 1; j >= 1; j--) cout << i << " " << j << endl;
  }
  return 0;
}
