#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
using namespace std;
vector<pair<int, pair<int, int> > > V, H;
bool getmask(pair<int, pair<int, int> > i, pair<int, pair<int, int> > j) {
  return j.second.first <= i.first && i.first <= j.second.second &&
         i.second.first <= j.first && j.first <= i.second.second;
}
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    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)
      V.emplace_back(make_pair(x1, make_pair(y1, y2)));
    else
      H.emplace_back(make_pair(y1, make_pair(x1, x2)));
  }
  if (H.size() > V.size()) swap(H, V);
  vector<bitset<5000> > mask(1 * H.size());
  for (int i = 0; i < H.size(); ++i) {
    for (int j = 0; j < V.size(); ++j) {
      mask[i][j] = getmask(H[i], V[j]);
    }
  }
  long long ans = 0ll;
  for (int i = 0; i < H.size(); ++i) {
    for (int j = i + 1; j < H.size(); ++j) {
      int cnt = (mask[i] & mask[j]).count();
      ans += 1ll * cnt * (cnt - 1) / 2;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
