#include <bits/stdc++.h>
using namespace std;
bool intr(pair<int, pair<int, int> >& a, pair<int, pair<int, int> >& b) {
  return (a.first >= b.second.first && a.first <= b.second.second &&
          b.first >= a.second.first && b.first <= a.second.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<pair<int, pair<int, int> > > ver, hor;
  for (int i = 0, a, b, c, d; i < n; ++i) {
    cin >> a >> b >> c >> d;
    if (b == d)
      hor.push_back({b, {min(a, c), max(a, c)}});
    else
      ver.push_back({a, {min(b, d), max(b, d)}});
  }
  if ((int)(ver).size() > (int)(hor).size()) swap(ver, hor);
  vector<bitset<5000> > btst((int)(ver).size());
  for (int i = 0; i < (int)(ver).size(); ++i)
    for (int j = 0; j < (int)(hor).size(); ++j)
      btst[i][j] = intr(ver[i], hor[j]);
  long long int ans = 0;
  for (int i = 0; i < (int)(ver).size(); ++i)
    for (int j = i + 1; j < (int)(ver).size(); ++j) {
      long long int c = (btst[i] & btst[j]).count();
      ans += (c * (c - 1)) / 2;
    }
  cout << ans << endl;
  return 0;
}
