#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 13;
vector<pair<int, int> > r[maxn], l[maxn];
vector<int> cun[maxn];
struct BIT {
  int a[maxn];
  void add(int x, int ad) {
    for (; x <= maxn - 2; x += x & (-x)) a[x] += ad;
  }
  int query(int x) {
    int ans = 0;
    for (; x; x -= x & (-x)) ans += a[x];
    return ans;
  }
  int get(int l, int r) { return query(r) - query(l - 1); }
  void clear() { memset(a, 0, sizeof(a)); }
} bit;
int main() {
  int n;
  scanf("%d", &n);
  int x1, y1, x2, y2;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    x1 += 5001, y1 += 5001, x2 += 5001, y2 += 5001;
    if (y1 == y2)
      r[y1].push_back({min(x1, x2), max(x1, x2)});
    else
      l[x1].push_back({min(y1, y2), max(y1, y2)});
  }
  n = maxn - 2;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (auto p : r[i]) {
      bit.clear();
      for (int j = p.first; j <= p.second; j++) {
        for (auto v : l[j]) {
          if (v.first <= i && v.second > i) {
            cun[v.second].push_back(j);
            bit.add(j, 1);
          }
        }
      }
      for (int j = i + 1; j <= n; j++) {
        for (auto p2 : r[j]) {
          int res = bit.get(p2.first, p2.second);
          ans += 1ll * res * (res - 1) / 2;
        }
        for (auto p2 : cun[j]) {
          bit.add(p2, -1);
        }
        cun[j].clear();
      }
    }
  }
  printf("%lld", ans);
}
