#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const long long int inf = 10000000000000000LL;
const long long int mod = 1000000007;
bool check(vector<int> arr) {
  sort(arr.begin(), arr.end());
  long long int a = arr[3] - arr[0];
  long long int m = arr[0] + arr[1] + arr[2] + arr[3];
  long long int g = arr[1] + arr[2];
  if (g % 2 == 0 && m % 4 == 0 && g / 2 == m / 4 && m / 4 == a) {
    return true;
  } else {
    return false;
  }
}
struct St {
  long long int a, b;
};
int a[1000010];
int main() {
  srand(13);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(2);
  int start = clock();
  int n, m, k;
  cin >> n >> m >> k;
  cout << (m * (m - 1) / 2) << endl;
  if (k == 0) {
    for (int i = 0; i < (m - 1); ++i) {
      for (int j = 0; j < m - i - 1; ++j) {
        cout << (j + 1) << " " << (j + 2) << "\n";
      }
    }
  } else {
    for (int i = 0; i < (m - 1); ++i) {
      for (int j = 0; j < m - i - 1; ++j) {
        cout << (j + 2) << " " << (j + 1) << "\n";
      }
    }
  }
  return 0;
}
