#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first - a.second) > (b.first - b.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<pair<pair<int, int>, pair<int, int>>> hor, ver;
  for (int i = 0; i < n; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    pair<int, int> t1 = {a, b};
    pair<int, int> t2 = {c, d};
    if (b == d)
      hor.push_back({min(t1, t2), max(t1, t2)});
    else
      ver.push_back({min(t1, t2), max(t1, t2)});
    ;
  }
  sort(hor.begin(), hor.end());
  sort(ver.begin(), ver.end());
  int vern = ver.size();
  vector<bitset<5000>> btst(vern);
  for (int i = 0; i < ver.size(); ++i) {
    for (int j = 0; j < hor.size(); j++) {
      int lev = hor[j].first.second;
      int a = hor[j].first.first;
      int b = hor[j].second.first;
      int pl = ver[i].first.first;
      int p = ver[i].first.second;
      int q = ver[i].second.second;
      bool flag = true;
      if (!(lev >= min(p, q) && lev <= max(p, q))) flag = false;
      if (!(pl >= min(a, b) && pl <= max(a, b))) flag = false;
      if (flag) btst[i][j] = 1;
    }
  }
  long long int ans = 0;
  for (int i = 0; i < ver.size(); ++i) {
    for (int j = i + 1; j < ver.size(); ++j) {
      int cn = (btst[i] & btst[j]).count();
      ans += (cn * (cn - 1)) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
