#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, sgn = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') sgn = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  return x * sgn;
}
const int N = 1e5 + 10;
int n;
long long ans1, ans2;
struct line {
  int x, y, l, r;
} seg[N];
bool cmp1(line a, line b) { return a.x < b.x; }
bool cmp2(line a, line b) { return a.y < b.y; }
struct BITT {
  int arr[N << 1];
  void add(int x, int v = 1) {
    for (; x <= (n * 2); x += x & -x) arr[x] += v;
    return;
  }
  int q(int x, int v = 0) {
    for (; x; x -= x & -x) v += arr[x];
    return v;
  }
  void clear() { memset(arr, 0, sizeof(arr)); }
} BIT;
int main() {
  n = read();
  for (int i = 1; i <= n; i++) seg[i].x = read(), seg[i].y = read();
  for (int i = 1; i <= n; i++)
    if (seg[i].x > seg[i].y) swap(seg[i].x, seg[i].y);
  sort(seg + 1, seg + n + 1, cmp1);
  for (int i = 1; i <= n; i++) {
    seg[i].l += BIT.q(seg[i].x) + BIT.q(n << 1) - BIT.q(seg[i].y);
    BIT.add(seg[i].y);
  }
  BIT.clear();
  for (int i = n; i >= 1; i--) {
    seg[i].r += BIT.q(seg[i].y);
    BIT.add(seg[i].y);
  }
  BIT.clear();
  sort(seg + 1, seg + n + 1, cmp2);
  for (int i = n; i >= 1; i--) {
    seg[i].l += BIT.q(n << 1) - BIT.q(seg[i].y);
    BIT.add(seg[i].x);
  }
  ans1 = 1ll * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; i++) {
    ans1 -= 1ll * seg[i].l * seg[i].r;
    ans2 += 1ll * (seg[i].l + seg[i].r) * (n - seg[i].l - seg[i].r - 1);
  }
  printf("%lld\n", ans1 - ans2 / 2);
  return 0;
}
