#include <bits/stdc++.h>
using namespace std;
const int N = 1000001, M = 11111111;
long long MOD = 998244353, inv2 = (MOD + 1) / 2;
int INF = int(1e9);
long double eps = 1e-8;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
long double pi = acos(-1.0L);
int read() {
  int v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
long long readll() {
  long long v = 0, f = 1;
  char c = getchar();
  while (c < 48 || 57 < c) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
  return v * f;
}
struct heng {
  int x1, x2, y;
} a[N];
struct shu {
  int y1, y2, x;
} b[N];
bitset<5555> B[5555];
int n, m;
void init() {
  int n1 = read();
  n = 0, m = 0;
  int x1, y1, x2, y2;
  for (int i = (int)1; i <= (int)n1; i++) {
    x1 = read(), y1 = read(), x2 = read(), y2 = read();
    if (x1 > x2) swap(x1, x2);
    if (y1 > y2) swap(y1, y2);
    if (y1 == y2)
      a[++n].x1 = x1, a[n].x2 = x2, a[n].y = y1;
    else
      b[++m].y1 = y1, b[m].y2 = y2, b[m].x = x1;
  }
}
void solve() {
  long long ans = 0;
  if (n < m) {
    for (int i = (int)1; i <= (int)n; i++)
      for (int j = (int)1; j <= (int)m; j++)
        if (b[j].y1 <= a[i].y && a[i].y <= b[j].y2 && a[i].x1 <= b[j].x &&
            b[j].x <= a[i].x2)
          B[i][j] = 1;
    for (int i = (int)1; i <= (int)n; i++)
      for (int j = (int)i + 1; j <= (int)n; j++) {
        int s = (B[i] & B[j]).count();
        ans += 1ll * s * (s - 1) / 2;
      }
  } else {
    for (int i = (int)1; i <= (int)m; i++)
      for (int j = (int)1; j <= (int)n; j++)
        if (b[i].y1 <= a[j].y && a[j].y <= b[i].y2 && a[j].x1 <= b[i].x &&
            b[i].x <= a[j].x2)
          B[i][j] = 1;
    for (int i = (int)1; i <= (int)m; i++)
      for (int j = (int)i + 1; j <= (int)m; j++) {
        int s = (B[i] & B[j]).count();
        ans += 1ll * s * (s - 1) / 2;
      }
  }
  printf("%I64d\n", ans);
}
int main() {
  init();
  solve();
  return 0;
}
