#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  short n, a, b, c, d;
  cin >> n;
  vector<pair<short, pair<short, short>>> x, y;
  for (short i = 0; i < n; i += 1) {
    cin >> a >> b >> c >> d;
    if (a > c) {
      swap(a, c);
    }
    if (b > d) {
      swap(b, d);
    }
    if (a == c) {
      x.push_back({c, {b, d}});
    } else {
      y.push_back({b, {a, c}});
    }
  }
  if (y.size() > 100) {
    int siz = x.size();
    bitset<5005> z[siz];
    for (short i = 0; i < x.size(); i += 1) {
      for (short j = 0; j < y.size(); j += 1) {
        if (x[i].second.first <= y[j].first &&
            x[i].second.second >= y[j].first) {
          if (y[j].second.first <= x[i].first &&
              y[j].second.second >= x[i].first) {
            z[i][j] = 1;
          }
        }
      }
    }
    long long ans = 0;
    for (short i = 0; i < x.size(); i += 1) {
      for (short j = i + 1; j < x.size(); j += 1) {
        long long val = (z[i] & z[j]).count();
        ans += val * (val - 1) / 2;
      }
    }
    cout << ans;
  } else {
    int siz = x.size();
    bitset<105> z[siz];
    for (short i = 0; i < x.size(); i += 1) {
      for (short j = 0; j < y.size(); j += 1) {
        if (x[i].second.first <= y[j].first &&
            x[i].second.second >= y[j].first) {
          if (y[j].second.first <= x[i].first &&
              y[j].second.second >= x[i].first) {
            z[i][j] = 1;
          }
        }
      }
    }
    long long ans = 0;
    for (short i = 0; i < x.size(); i += 1) {
      for (short j = i + 1; j < x.size(); j += 1) {
        long long val = (z[i] & z[j]).count();
        ans += val * (val - 1) / 2;
      }
    }
    cout << ans;
  }
}
