#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > vertical[10006];
vector<pair<int, int> > horizontal[10006];
int BIT[10006], n;
void update(int ix, int val) {
  ix = ix + 1;
  for (; ix <= 10006; ix += ix & (-ix)) {
    BIT[ix] += val;
  }
}
int sum(int ix) {
  ix = ix + 1;
  int sume = 0;
  for (; ix > 0; ix -= ix & (-ix)) {
    sume += BIT[ix];
  }
  return sume;
}
int getsum(int a, int b) { return sum(b) - sum(a - 1); }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a += 5000;
    b += 5000;
    c += 5000;
    d += 5000;
    if (a == c) {
      int y1 = min(b, d);
      int y2 = max(b, d);
      vertical[a].push_back(make_pair(y1, y2));
    } else {
      int x1 = min(a, c);
      int x2 = max(a, c);
      horizontal[b].push_back(make_pair(x1, x2));
    }
  }
  long long ans = 0;
  for (int y = 0; y <= 10000; y++) {
    for (int i = 0; i < horizontal[y].size(); i++) {
      vector<int> puncak[10009];
      memset(BIT, 0, sizeof(BIT));
      pair<int, int> alas = horizontal[y][i];
      for (int x = alas.first; x <= alas.second; x++) {
        for (int v = 0; v < vertical[x].size(); v++) {
          pair<int, int> tiang = vertical[x][v];
          if (tiang.first <= y && tiang.second > y) {
            puncak[tiang.second].push_back(x);
            update(x, 1);
          }
        }
      }
      for (int y2 = y + 1; y2 <= 10000; y2++) {
        for (int h = 0; h < horizontal[y2].size(); h++) {
          pair<int, int> tutup = horizontal[y2][h];
          int cnt = getsum(tutup.first, tutup.second);
          ans += (cnt * (cnt - 1)) / 2;
        }
        for (int x = 0; x < puncak[y2].size(); x++) {
          update(puncak[y2][x], -1);
        }
      }
    }
  }
  cout << ans << endl;
}
