#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long x1, y1, x2, y2;
} r[5005], c[5005];
bitset<5005> f[2505];
int main() {
  long long i, j, t, x1, y1, x2, y2, n, t1 = 0, t2 = 0, ans = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 > x2) swap(x1, x2);
    if (y1 > y2) swap(y1, y2);
    if (y1 == y2)
      r[++t1] = (Node){x1, y1, x2, y2};
    else
      c[++t2] = (Node){x1, y1, x2, y2};
  }
  if (t1 < t2) {
    for (i = 1; i <= t1; i++)
      for (j = 1; j <= t2; j++)
        if (r[i].x1 <= c[j].x1 && r[i].x2 >= c[j].x1 && c[j].y1 <= r[i].y1 &&
            c[j].y2 >= r[i].y2)
          f[i][j] = 1;
    for (i = 1; i <= t1; i++)
      for (j = i + 1; j <= t1; j++) {
        t = (f[i] & f[j]).count();
        ans += 1ll * t * (t - 1) / 2;
      }
  } else {
    for (i = 1; i <= t1; i++)
      for (j = 1; j <= t2; j++)
        if (r[i].x1 <= c[j].x1 && r[i].x2 >= c[j].x1 && c[j].y1 <= r[i].y1 &&
            c[j].y2 >= r[i].y2)
          f[j][i] = 1;
    for (i = 1; i <= t2; i++)
      for (j = i + 1; j <= t2; j++) {
        t = (f[i] & f[j]).count();
        ans += 1ll * t * (t - 1) / 2;
      }
  }
  cout << ans << endl;
  return 0;
}
