#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1;
long long arr[maxn], n, m, t, k;
unordered_map<long long, long long> u;
long long __min(long long a, long long b) { return a < b ? a : b; }
long long __max(long long a, long long b) { return a > b ? a : b; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> m >> n >> k;
  vector<pair<long long, long long> > arr;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) arr.push_back({i, j});
  cout << arr.size() << "\n";
  for (pair<long long, long long> p : arr) {
    if (k)
      cout << n - p.first + 1 << " " << n - p.second + 1 << "\n";
    else
      cout << p.first << " " << p.second << "\n";
  }
}
