#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} xd[100001], a[200001];
int x[100001], y[100001], n, tree[200001][2];
long long ans, ans1;
bool cmp(node x, node y) { return x.x < y.x; }
void update(int x, int y) {
  for (int i = x; i <= 2 * n; i += i & (-i)) tree[i][y]++;
}
int sum(int x, int y) {
  int s = 0;
  for (int i = x; i; i -= i & (-i)) s += tree[i][y];
  return s;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &xd[i].x, &xd[i].y);
    if (xd[i].x > xd[i].y) swap(xd[i].x, xd[i].y);
    a[i * 2 - 1].x = xd[i].x;
    a[i * 2 - 1].y = i;
    a[i * 2].x = xd[i].y;
    a[i * 2].y = i + n;
    update(xd[i].x, 0);
  }
  sort(a + 1, a + n * 2 + 1, cmp);
  for (int i = 1; i <= 2 * n; i++)
    if (a[i].y <= n) {
      update(xd[a[i].y].y, 1);
      x[a[i].y] = sum(2 * n, 1) - sum(xd[a[i].y].y, 1);
      y[a[i].y] = sum(xd[a[i].y].y - 1, 1) - sum(xd[a[i].y].x - 1, 1);
    } else {
      int j = a[i].y - n;
      x[j] += sum(xd[j].x, 1) + sum(2 * n, 0) - sum(xd[j].y - 1, 0);
      y[j] = sum(xd[j].y - 1, 1) - sum(xd[j].x - 1, 1) - y[j];
    }
  ans = 1ll * n * (n - 1) * (n - 2) / 6;
  for (int i = 1; i <= n; i++)
    ans -= 1ll * x[i] * y[i],
        ans1 += 1ll * (x[i] + y[i]) * (n - x[i] - y[i] - 1);
  printf("%lld", ans - ans1 / 2);
  return 0;
}
