#include <bits/stdc++.h>
using namespace std;
class Segment {
 public:
  long long x1, x2, y1, y2;
  Segment(long long a1, long long a2, long long b1, long long b2) {
    if (a1 > a2) swap(a1, a2);
    if (b1 > b2) swap(b1, b2);
    x1 = a1;
    x2 = a2;
    y1 = b1;
    y2 = b2;
  }
  bool isFlat() { return y1 == y2; }
};
bool intersect(Segment& a, Segment& b) {
  if (a.isFlat() and !b.isFlat())
    return (a.x1 <= b.x1 and b.x1 <= a.x2) and (b.y1 <= a.y1 and a.y1 <= b.y2);
  if (b.isFlat() and !a.isFlat())
    return (b.x1 <= a.x1 and a.x1 <= b.x2) and (a.y1 <= b.y1 and b.y1 <= a.y2);
  return false;
}
int main() {
  long long n;
  cin >> n;
  vector<Segment> h, v;
  for (long long i = 0; i < n; i++) {
    long long x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Segment s(x1, x2, y1, y2);
    if (s.isFlat())
      h.push_back(s);
    else
      v.push_back(s);
  }
  vector<vector<unsigned long long>> bits;
  for (long long i = 0; i < h.size(); i++) {
    vector<unsigned long long> tb;
    long long mask = 0, cnt = 0;
    for (long long j = 0; j < v.size(); j++) {
      if (intersect(h[i], v[j])) mask |= 1 << (j % 32);
      cnt++;
      if (cnt == 32) {
        tb.push_back(mask);
        mask = 0;
        cnt = 0;
      }
    }
    if (cnt) tb.push_back(mask);
    bits.push_back(tb);
  }
  long long ans = 0;
  for (long long i = 0; i < h.size(); i++) {
    for (long long j = i + 1; j < h.size(); j++) {
      long long x = 0;
      for (long long k = 0; k < bits[i].size(); k++)
        x += __builtin_popcount(bits[i][k] & bits[j][k]);
      ans += (x * (x - 1)) / 2;
    }
  }
  cout << ans;
  return 0;
}
