#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 10;
const double pi = acos(-1.0);
const double eps = 1e-8;
struct node1 {
  int y, x1, x2;
} a[5050];
int tp1;
struct node2 {
  int x, y1, y2;
} b[5050];
int tp2;
bitset<5050> bs[5050];
int main() {
  int n;
  tp1 = tp2 = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      b[++tp2].x = x1;
      if (y1 > y2) swap(y1, y2);
      b[tp2].y1 = y1;
      b[tp2].y2 = y2;
    } else {
      a[++tp1].y = y1;
      if (x1 > x2) swap(x1, x2);
      a[tp1].x1 = x1;
      a[tp1].x2 = x2;
    }
  }
  if (tp1 > tp2) {
    int tp = max(tp1, tp2);
    for (int i = 1; i <= tp; i++) {
      int tmp = a[i].y;
      a[i].y = b[i].x;
      b[i].x = tmp;
      tmp = a[i].x1;
      a[i].x1 = b[i].y1;
      b[i].y1 = tmp;
      tmp = a[i].x2;
      a[i].x2 = b[i].y2;
      b[i].y2 = tmp;
    }
    swap(tp1, tp2);
  }
  for (int i = 1; i <= tp1; i++) {
    for (int j = 1; j <= tp2; j++) {
      if (a[i].y >= b[j].y1 && a[i].y <= b[j].y2 && b[j].x >= a[i].x1 &&
          b[j].x <= a[i].x2) {
        bs[i][j] = 1;
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i < tp1; i++) {
    if (bs[i].count() == 0) continue;
    for (int j = i + 1; j <= tp1; j++) {
      bitset<5050> bb = bs[i] & bs[j];
      int tmp = bb.count();
      ans += tmp * (tmp - 1) / 2;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
