#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 7;
vector<array<int, 3> > v1, v2;
bool intersect(const array<int, 3>& lhs, const array<int, 3>& rhs) {
  if (lhs[0] < rhs[1] || lhs[0] > rhs[2]) return 0;
  return rhs[0] >= lhs[1] && rhs[0] <= lhs[2];
}
int bit[N];
void add(int x) {
  for (; x < N; x += x & -x) bit[x]++;
}
int sum(int x) {
  int ret = 0;
  for (; x; x -= x & -x) ret += bit[x];
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  int x1, x2, y1, y2;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    x1 += 5001, x2 += 5001;
    y1 += 5001, y2 += 5001;
    if (x1 == x2) {
      if (y1 > y2) swap(y1, y2);
      v1.push_back({x1, y1, y2});
    } else {
      if (x1 > x2) swap(x1, x2);
      v2.push_back({y1, x1, x2});
    }
  }
  auto cmp = [&](const array<int, 3>& lhs, const array<int, 3>& rhs) {
    return lhs[1] < rhs[1];
  };
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end(), cmp);
  int l1 = v1.size(), l2 = v2.size();
  long long ans = 0;
  for (int i = 0; i < l1; i++) {
    vector<array<int, 3> > t;
    for (int j = 0; j < l2; j++)
      if (intersect(v1[i], v2[j])) t.push_back(v2[j]);
    int lt = t.size();
    memset(bit, 0, sizeof bit);
    for (int j = 0, p = 0; j < i; j++) {
      while (p < lt && t[p][1] <= v1[j][0]) add(t[p++][0]);
      int cnt = sum(v1[j][2]) - sum(v1[j][1] - 1);
      ans += cnt * (cnt - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
