#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
const int N = 1e4 + 10;
const long long mod = 1e9 + 7;
const bool debug = false;
int mid = 5005;
pair<pair<int, int>, int> ho[N], ve[N];
struct BITstree {
  int node[N];
  void init() { memset(node, 0, sizeof node); }
  int sum(int x) {
    int ret = 0;
    for (; x; x -= (x & (-x))) ret += node[x];
    return ret;
  }
  void up(int x, int n, int d) {
    for (; x <= n; x += (x & (-x))) node[x] += d;
  }
} bit;
bool cmp(pair<pair<int, int>, int> x, pair<pair<int, int>, int> y) {
  return x.second < y.second;
}
bool cmp2(pair<pair<int, int>, int> x, pair<pair<int, int>, int> y) {
  return x.first.first < y.first.first;
}
int main() {
  int n, tot1 = 0, tot2 = 0;
  scanf("%d", &n);
  for (int i = 1, x1, x2, y1, y2; i <= n; ++i) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    x1 += mid, x2 += mid, y1 += mid, y2 += mid;
    if (x1 == x2) {
      if (y1 > y2) swap(y1, y2);
      ho[++tot1] = {{y1, y2}, x1};
    } else {
      if (x1 > x2) swap(x1, x2);
      ve[++tot2] = {{x1, x2}, y1};
    }
  }
  long long ans = 0;
  sort(ho + 1, ho + tot1 + 1, cmp);
  sort(ve + 1, ve + tot2 + 1, cmp2);
  int mx = N - 1;
  for (int i = 2; i <= tot1; ++i) {
    bit.init();
    for (int j = 1, k = 1, si; j < i; ++j) {
      while (k <= tot2 && ve[k].first.first <= ho[j].second) {
        if (ve[k].first.second >= ho[i].second &&
            ve[k].second >= ho[i].first.first &&
            ve[k].second <= ho[i].first.second)
          bit.up(ve[k].second, mx, 1);
        k++;
      }
      si = (bit.sum(ho[j].first.second) - bit.sum(ho[j].first.first - 1));
      ans += si * 1ll * (si - 1) / 2;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
