#include <bits/stdc++.h>
using namespace std;
int A[10000][2];
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  int cur = 0;
  for (int i = 0; i < M; i++)
    for (int j = (i + 1); j < M; j++) {
      A[cur][K] = i + 1;
      A[cur][1 - K] = j + 1;
      cur++;
    }
  cout << cur << endl;
  for (int i = 0; i < cur; i++) cout << A[i][0] << " " << A[i][1] << endl;
  return 0;
}
