#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 10;
const int INF = 0x3f3f3f3f;
struct node {
  int x1, y1, x2, y2;
} R[5000 + 10], C[5000 + 10];
bitset<5000 + 10> p1[5000 + 10], p2[5000 + 10];
bool judge(node i, node j) {
  if (i.y2 >= j.y1 && j.y1 >= i.y1 && j.x2 >= i.x1 && i.x1 >= j.x1) return true;
  return false;
}
int main() {
  int n, a, b, c, d;
  int sum1 = 0, sum2 = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if (a == c) {
      R[sum1].x1 = a;
      R[sum1].y1 = min(b, d);
      R[sum1].x2 = c;
      R[sum1++].y2 = max(b, d);
    } else {
      C[sum2].x1 = min(a, c);
      C[sum2].y1 = b;
      C[sum2].x2 = max(a, c);
      C[sum2++].y2 = d;
    }
  }
  for (int i = 0; i < sum1; i++) {
    for (int j = 0; j < sum2; j++) {
      if (judge(R[i], C[j])) {
        p1[i][j] = 1;
        p2[j][i] = 1;
      }
    }
  }
  long long res = 0, sum;
  int N = min(sum1, sum2);
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (sum1 < sum2)
        sum = (p1[i] & p1[j]).count();
      else
        sum = (p2[i] & p2[j]).count();
      res += sum * (sum - 1) / 2;
    }
  }
  printf("%lld\n", res);
  return 0;
}
