#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > all;
long long v1[100010], v2[100010];
int T[200010];
void modify(int x, int v) {
  while (x <= 200005) T[x] += v, x += x & -x;
}
int query(int x) {
  int res = 0;
  while (x) res += T[x], x -= x & -x;
  return res;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x > y) swap(x, y);
    all.push_back(make_pair(make_pair(x, y), i));
  }
  sort(all.rbegin(), all.rend());
  memset(T, 0, sizeof(T));
  for (int i = 0; i < all.size(); i++)
    v1[all[i].second] = query(all[i].first.second),
    modify(all[i].first.second, 1);
  memset(T, 0, sizeof(T));
  for (int i = 0; i < all.size(); i++)
    v2[all[i].second] = i - query(all[i].first.second),
    modify(all[i].first.first, 1);
  sort(all.begin(), all.end());
  memset(T, 0, sizeof(T));
  for (int i = 0; i < all.size(); i++)
    v2[all[i].second] += query(all[i].first.first),
        modify(all[i].first.second, 1);
  memset(T, 0, sizeof(T));
  for (int i = 0; i < all.size(); i++)
    v2[all[i].second] += i - query(all[i].first.second),
        modify(all[i].first.second, 1);
  long long ans = 1ll * n * (n - 1) * (n - 2) / 6, sum = 0;
  for (int i = 0; i < n; i++)
    ans -= v1[i] * v2[i], sum += (v1[i] + v2[i]) * (n - v1[i] - v2[i] - 1);
  ans -= sum / 2;
  printf("%I64d\n", ans);
  return 0;
}
