#include <bits/stdc++.h>
using namespace std;
const double PI = atan(1.0) * 4;
int table[10004] = {0};
int n;
inline void update(int i, int delta) {
  while (i <= 10004) {
    table[i] += delta;
    i += (i & -i);
  }
}
inline int pref_sum(int i) {
  int sum = 0;
  while (i > 0) {
    sum += table[i];
    i -= i & -i;
  }
  return sum;
}
vector<pair<pair<int, int>, int>> ver;
vector<pair<int, pair<int, int>>> hor;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a += 5002;
    b += 5002;
    c += 5002;
    d += 5002;
    if (a == c)
      ver.push_back({{max(b, d), a}, min(b, d)});
    else
      hor.push_back({b, {min(a, c), max(a, c)}});
  }
  long long int ans = 0;
  sort(hor.begin(), hor.end());
  sort(ver.begin(), ver.end());
  for (int i = 0; i < hor.size(); i++) {
    vector<pair<int, int>> good;
    int x1 = hor[i].second.first;
    int x2 = hor[i].second.second;
    int y = hor[i].first;
    for (int j = 0; j < ver.size(); j++) {
      if ((ver[j].first.second) >= x1 && (ver[j].first.second) <= x2 &&
          (ver[j].second) <= y) {
        good.push_back({ver[j].first.first, ver[j].first.second});
        update(ver[j].first.second, 1);
      }
    }
    int ptr1 = i + 1, ptr2 = 0;
    while (ptr1 < hor.size() && ptr2 < good.size()) {
      int y1 = hor[ptr1].first;
      int y2 = good[ptr2].first;
      if (y1 <= y2) {
        long long int tot = pref_sum(hor[ptr1].second.second) -
                            pref_sum(hor[ptr1].second.first - 1);
        ans += (long long int)(tot * (tot - 1)) / 2;
        ptr1++;
      } else {
        update(good[ptr2].second, -1);
        ptr2++;
      }
    }
    while (ptr2 < good.size()) {
      update(good[ptr2].second, -1);
      ptr2++;
    }
  }
  cout << ans << endl;
  return 0;
}
