For given $n$ segments which are parallel to X-axis or Y-axis, find the number of intersections of them.

Constraints

* $1 \leq n \leq 100,000$
* $ -1,000,000,000 \leq x_1, y_1, x_2, y_2 \leq 1,000,000,000$
* Two parallel segments never overlap or touch.
* The number of intersections $\leq 1,000,000$

Input

In the first line, the number of segments $n$ is given. In the following $n$ lines, the $i$-th segment is given by coordinates of its end points in the following format:

$x_1 \; y_1 \; x_2 \; y_2$

The coordinates are given in integers.

Output

Print the number of intersections in a line.

Example

Input

6
2 2 2 5
1 3 5 3
4 1 4 4
5 2 7 2
6 1 6 3
6 5 6 7


Output

3
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

struct IntL {
    long long pos;
    long long s;
    long long t;
};

bool comp_intl(const IntL &a, const IntL &b) {
    return a.pos < b.pos;
}

int main() {

    int N;
    cin >> N;

    vector<IntL> vx;
    vector<IntL> vy;

    for (int i = 0; i < N; i++) {
        long long x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (x1 == x2) {
            IntL intL = {x1, min(y1, y2), max(y1, y2)};
            vy.push_back(intL);
        }
        if (y1 == y2) {
            IntL intL = {y1, min(x1, x2), max(x1, x2)};
            vx.push_back(intL);
        }
    }

    sort(vy.begin(), vy.end(), comp_intl);

    long long ans = 0;
    for (auto li: vx) {
        long long left = li.s;
        long long right = li.t;
        long long posY = li.pos;
        auto s1 = lower_bound(vy.begin(), vy.end(), (IntL) {left, LONG_LONG_MIN, LONG_LONG_MIN}, comp_intl);
        auto s2 = upper_bound(vy.begin(), vy.end(), (IntL) {right, LONG_LONG_MIN, LONG_LONG_MIN}, comp_intl);
        for (auto i = s1; i != s2; i++) {
            if (i->s <= posY && posY <= i->t) ans++;
        }
    }

    cout << ans << endl;

}












































