#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
int tr[N * 4], M, n;
int px[N], py[N], ax[N], ay[N];
int ty[N], fr[N];
long long ans1, ans2, ans;
void add(int x) {
  for (x += M; x; x >>= 1) tr[x]++;
}
int Q(int l, int r) {
  if (l > r) return 0;
  int ans = 0;
  for (l += M - 1, r += M + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
    if (!(l & 1)) ans += tr[l ^ 1];
    if (r & 1) ans += tr[r ^ 1];
  }
  return ans;
}
int main() {
  cin >> n;
  ans = n;
  for (M = 1; M <= n * 2; M <<= 1)
    ;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &px[i], &py[i]);
    if (px[i] > py[i]) swap(px[i], py[i]);
    ty[px[i]] = 0, fr[px[i]] = i;
    ty[py[i]] = 1, fr[py[i]] = i;
  }
  for (int i = 1; i <= n * 2; i++) {
    if (!ty[i]) {
      add(py[fr[i]]);
      ax[fr[i]] -= Q(1, py[fr[i]]);
      ay[fr[i]] += Q(1, i) + Q(py[fr[i]] + 1, 2 * n);
    } else
      ax[fr[i]] += Q(1, i);
  }
  memset(tr, 0, sizeof tr);
  for (int i = n * 2; i; i--) {
    if (ty[i]) {
      add(px[fr[i]]);
      ay[fr[i]] += Q(i, 2 * n);
    }
  }
  for (int i = 1; i <= n; i++) {
    ans1 += (long long)ax[i] * ay[i];
    ans2 += ((long long)ax[i] + ay[i]) * (n - ax[i] - ay[i] - 1);
  }
  cout << ans * (ans - 1) * (ans - 2) / 6 - ans1 - ans2 / 2 << endl;
}
