#include <bits/stdc++.h>
using namespace std;
int c[110000 * 2], n;
struct rec {
  int l, r, s1, s2, s3;
} a[110000];
bool cmp1(rec a, rec b) { return a.r < b.r; }
bool cmp2(rec a, rec b) { return a.r > b.r; }
bool cmp3(rec a, rec b) { return a.l < b.l; }
int lowbit(int x) { return x & (-x); }
void add(int x, int w) {
  for (; x <= n * 2; x += lowbit(x)) c[x] += w;
}
int find(int x) {
  int ans = 0;
  for (; x; x -= lowbit(x)) ans += c[x];
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].l, &a[i].r);
    if (a[i].l > a[i].r) swap(a[i].l, a[i].r);
    a[i].s1 = a[i].s2 = 0;
  }
  sort(a + 1, a + n + 1, cmp1);
  memset(c, 0, sizeof c);
  for (int i = 1; i <= n; i++) {
    int t1 = i - 1, t2 = find(a[i].l);
    a[i].s1 += t1 - t2;
    add(a[i].l, 1);
  }
  sort(a + 1, a + n + 1, cmp3);
  memset(c, 0, sizeof c);
  for (int i = 1; i <= n; i++) {
    a[i].s2 += find(a[i].l);
    add(a[i].r, 1);
  }
  sort(a + 1, a + n + 1, cmp2);
  memset(c, 0, sizeof c);
  for (int i = 1; i <= n; i++) {
    a[i].s2 += find(a[i].l);
    a[i].s2 += i - 1 - find(a[i].r);
    add(a[i].l, 1);
  }
  for (int i = 1; i <= n; i++) a[i].s3 = n - 1 - a[i].s1 - a[i].s2;
  long long ans = (long long)n * (n - 1) * (n - 2) / 6, tot1 = 0, tot2 = 0;
  for (int i = 1; i <= n; i++) {
    tot1 += (long long)(a[i].s1 + a[i].s2) * a[i].s3;
    tot2 += (long long)a[i].s1 * a[i].s2;
  }
  ans -= tot1 / 2 + tot2;
  cout << ans << endl;
  return 0;
}
