#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  cout << M * (M - 1) / 2 << endl;
  for (int I = 0; I < M; I++)
    for (int J = I + 1; J < M; J++)
      if (K)
        cout << J + 1 << " " << I + 1 << endl;
      else
        cout << I + 1 << " " << J + 1 << endl;
  return 0;
}
