#include <bits/stdc++.h>   using namespace std;   ;   const long long N = 5e3 + 10;   vector<bitset<N> > v;   vector<pair<long long, pair<long long, long long> > > hor, ver;   long long n, cnt, y11, y2, x1, x2;   long long ans;   bool check(long long x, pair<long long, long long> a) {     return a.first <= x && x <= a.second;   }   void solve() {     cin >> n;     for (long long i = 0; i < n; i++) {       cin >> x1 >> y11 >> x2 >> y2;       if (x1 > x2) swap(x1, x2);       if (y11 > y2) swap(y11, y2);       if (x1 == x2)         ver.push_back({x1, {y11, y2}});       else         hor.push_back({y11, {x1, x2}});     }     if ((long long)((hor).size()) > (long long)((ver).size())) swap(hor, ver);     v.resize((long long)((hor).size()));     for (long long i = 0; i < (long long)((hor).size()); i++) {       for (long long j = 0; j < (long long)((ver).size()); j++) {         v[i][j] = check(hor[i].first, ver[j].second) &&                   check(ver[j].first, hor[i].second);       }     }     for (long long i = 0; i < (long long)((v).size()); i++) {       for (long long j = i + 1; j < (long long)((v).size()); j++) {         cnt = (v[i] & v[j]).count();         ans += cnt * (cnt - 1) / 2;       }     }     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     clock_t start, end;     start = clock();     cout << fixed << setprecision(15);     while (t--) {       solve();     }     end = clock();     double time_taken = double(end - start) / double(CLOCKS_PER_SEC);   }   