#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
int n, m, sum, gs1, gs2, c[N], vis[N];
long long ans;
struct node1 {
  int y, x, xx;
} a[N];
struct node2 {
  int x, y, yy;
} b[N];
bool cmp1(node1 a, node1 b) { return a.y < b.y; }
bool cmp2(node2 a, node2 b) { return a.yy < b.yy; }
int lowbit(int x) { return x & -x; }
int find(int x) {
  int res = 0;
  while (x > 0) {
    res += c[x];
    x -= lowbit(x);
  }
  return res;
}
void add(int x, int y) {
  while (x <= 10001) {
    c[x] += y;
    x += lowbit(x);
  }
}
signed main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y, xx, yy;
    scanf("%d%d%d%d", &x, &y, &xx, &yy);
    x += 5001, y += 5001, xx += 5001, yy += 5001;
    if (x == xx)
      b[++gs2] = (node2){x, min(y, yy), max(y, yy)};
    else
      a[++gs1] = (node1){y, min(x, xx), max(x, xx)};
  }
  sort(a + 1, a + gs1 + 1, cmp1);
  sort(b + 1, b + gs2 + 1, cmp2);
  for (int i = 1; i <= gs1; i++) {
    memset(c, 0, sizeof(c));
    for (int j = 1; j <= gs2; j++)
      if (b[j].y <= a[i].y && b[j].yy >= a[i].y) {
        add(b[j].x, 1);
        vis[j] = 1;
      } else
        vis[j] = 0;
    int k = 1;
    for (int j = i + 1; j <= gs1; j++) {
      while (k <= gs2 && b[k].yy < a[j].y) {
        if (vis[k]) add(b[k].x, -1);
        k++;
      }
      int r = min(a[i].xx, a[j].xx), l = max(a[i].x, a[j].x) - 1;
      if (l < r) {
        int x = find(r) - find(l);
        ans += 1ll * x * (x - 1) / 2;
      }
    }
  }
  cout << ans;
}
