#include <bits/stdc++.h>
using namespace std;
bool check(int x, pair<int, int> a) { return a.first <= x && x <= a.second; }
signed main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, pair<int, int>>> vert;
  vector<pair<int, pair<int, int>>> hor;
  while (n--) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 > x2) swap(x1, x2);
    if (y1 > y2) swap(y1, y2);
    if (x1 == x2) {
      vert.push_back({x1, {y1, y2}});
    } else {
      hor.push_back({y1, {x1, x2}});
    }
  }
  if (signed(hor.size()) < signed(vert.size())) swap(hor, vert);
  vector<bitset<5000>> inter(signed(vert.size()));
  for (int i = 0; i < signed(vert.size()); ++i)
    for (int j = 0; j < signed(hor.size()); ++j)
      inter[i][j] = check(hor[j].first, vert[i].second) &&
                    check(vert[i].first, hor[j].second);
  long long ans = 0;
  for (int i = 0; i < signed(vert.size()); ++i)
    for (int j = i + 1; j < signed(vert.size()); ++j) {
      int cnt = (inter[i] & inter[j]).count();
      ans += cnt * (cnt - 1) / 2;
    }
  printf("%I64d", ans);
  return 0;
}
