#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 100;
int BIT[N];
void Up(int u, int v) {
  for (; u < N; u += u & -u) BIT[u] += v;
}
int Get(int u) {
  int ans = 0;
  for (; u > 0; u -= u & -u) ans += BIT[u];
  return ans;
}
vector<pair<pair<int, int>, int> > Ver;
vector<pair<int, pair<int, int> > > Hor;
long long f(int x) { return 1ll * x * (x - 1) / 2; }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1 += 5e3 + 10;
    y1 += 5e3 + 10;
    x2 += 5e3 + 10;
    y2 += 5e3 + 10;
    if (x1 > x2) {
      swap(x1, x2);
    }
    if (y1 > y2) {
      swap(y1, y2);
    }
    if (x1 == x2) {
      Ver.push_back(make_pair(pair<int, int>(y2, y1), x1));
    } else
      Hor.push_back(make_pair(y1, pair<int, int>(x1, x2)));
  }
  sort(Hor.begin(), Hor.end());
  sort(Ver.begin(), Ver.end());
  long long ans = 0;
  for (int i = 0; i < Hor.size(); ++i) {
    for (auto x : Ver)
      if (x.first.second <= Hor[i].first) {
        Up(x.second, 1);
      }
    int it = 0;
    for (int j = i + 1; j < Hor.size(); ++j) {
      while (it < Ver.size() && Ver[it].first.first < Hor[j].first) {
        if (Ver[it].first.second <= Hor[i].first) Up(Ver[it].second, -1);
        ++it;
      }
      int L = max(Hor[i].second.first, Hor[j].second.first);
      int R = min(Hor[i].second.second, Hor[j].second.second);
      if (L <= R) ans += f(Get(R) - Get(L - 1));
    }
    while (it < Ver.size()) {
      if (Ver[it].first.second <= Hor[i].first) Up(Ver[it].second, -1);
      ++it;
    }
  }
  cout << ans;
}
