#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long power(int x, unsigned int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
char matrix[1000][1000];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int a[n + 5][m + 5];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  if (k == 0) {
    cout << m * (m - 1) / 2 << "\n";
    for (int i = 1; i <= m; i++)
      for (int j = i + 1; j <= m; j++) cout << i << " " << j << "\n";
  } else {
    cout << m * (m - 1) / 2 << "\n";
    for (int i = 1; i <= m; i++)
      for (int j = i + 1; j <= m; j++) cout << j << " " << i << "\n";
  }
  return 0;
}
