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