#include <bits/stdc++.h>
using namespace std;
int gi() {
  int res = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && !isdigit(ch)) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar();
  return res * w;
}
const int MAX_N = 2e5 + 5;
int N, L[MAX_N], R[MAX_N];
struct node {
  int x, y, id;
} p[MAX_N];
int c[MAX_N];
inline int lb(int x) { return x & -x; }
void add(int x, int v) {
  for (; x <= N << 1; x += lb(x)) c[x] += v;
}
int sum(int x) {
  int res = 0;
  for (; x; x -= lb(x)) res += c[x];
  return res;
}
int main() {
  N = gi();
  for (int i = 1; i <= N; i++) {
    int x = gi(), y = gi();
    if (x > y) swap(x, y);
    p[i] = (node){x, y, i};
  }
  sort(&p[1], &p[N + 1],
       [](const node &l, const node &r) { return l.x < r.x; });
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= N; i++)
    L[p[i].id] += sum(p[i].x - 1) + i - 1 - sum(p[i].y), add(p[i].y, 1);
  sort(&p[1], &p[N + 1],
       [](const node &l, const node &r) { return l.y > r.y; });
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= N; i++)
    L[p[i].id] += i - 1 - sum(p[i].y), add(p[i].x, 1);
  sort(&p[1], &p[N + 1],
       [](const node &l, const node &r) { return l.x > r.x; });
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= N; i++) R[p[i].id] += sum(p[i].y - 1), add(p[i].y, 1);
  long long ans1 = 1ll * N * (N - 1) * (N - 2) / 6, ans2 = 0;
  for (int i = 1; i <= N; i++) {
    ans1 -= 1ll * L[i] * R[i];
    ans2 += 1ll * (L[i] + R[i]) * (N - L[i] - R[i] - 1);
  }
  cout << ans1 - ans2 / 2 << endl;
  return 0;
}
