#include <bits/stdc++.h>
namespace {
using namespace std;
using ll = long long;
using ii = std::pair<int, int>;
using vi = std::vector<int>;
using vii = std::vector<ii>;
using vll = std::vector<ll>;
const int INF = 1e9;
const int MOD = 1e9 + 7;
template <typename T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T, typename U>
inline std::pair<T, U> mpair(T a, U b) {
  return std::make_pair(a, b);
}
int n, m, k;
}  // namespace
int main(int argc, const char* argv[]) {
  std::ios_base::sync_with_stdio(false);
  cin >> n >> m >> k;
  int cnt = (m * (m - 1)) / 2;
  cout << cnt << endl;
  for (int i = 1; i <= m; ++i) {
    for (int j = i + 1; j <= m; ++j) {
      if (k == 0) {
        cout << i << " " << j << endl;
      } else {
        cout << j << " " << i << endl;
      }
    }
  }
  return 0;
}
