#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
long long xpow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
void OUT(bool res) { cout << (res ? "YES" : "NO") << endl; }
void out(bool res) { cout << (res ? "Yes" : "No") << endl; }
bool between(int a, int b, int c) { return c <= b && c >= a; }
struct node {
  int a1, b1, a2, b2;
  friend bool co(node& x, node& y) {
    if (x.a1 == x.a2 && y.b1 == y.b2) {
      return between(x.b1, x.b2, y.b1) && between(y.a1, y.a2, x.a1);
    } else if (y.a1 == y.a2 && x.b1 == x.b2) {
      return between(y.b1, y.b2, x.b1) && between(x.a1, x.a2, y.a1);
    } else
      assert(false);
  }
};
vector<node> V1;
vector<node> V2;
bitset<5000> st[5000];
int main() {
  int n, a, b, c, d;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    if (a == c) {
      if (b > d) {
        swap(b, d);
      }
    }
    if (b == d) {
      if (a > c) {
        swap(a, c);
      }
    }
    node x = {a, b, c, d};
    if (a == c)
      V1.push_back(x);
    else
      V2.push_back(x);
  }
  if (V1.size() > V2.size()) swap(V1, V2);
  long long ans = 0;
  for (int i = 0; i < (int)V1.size(); i++) {
    for (int j = 0; j < (int)V2.size(); j++) {
      if (co(V1[i], V2[j])) st[i][j] = true;
    }
    for (int j = 0; j < i; j++) {
      long long res = (st[i] & st[j]).count();
      ans += (res) * (res - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
