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<bits/stdc++.h>
using namespace std;
long long bit[1000000], _size, n, cnt, __X1[200000], __Y1[200000], __X2[200000], __Y2[200000];
vector<long long>XX, YY, _XX, _YY; vector<tuple<long long, long long, long long>>vec;
void add(long long p, long long x) { while (p <= _size) { bit[p] += x; p += p&-p; } }
long long sum(long long p) { int _sum = 0; while (p >= 1) { _sum += bit[p]; p -= p&-p; }return _sum; }
long long __sum(long long l, long long r) { return sum(r) - sum(l - 1); }
int main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> __X1[i] >> __Y1[i] >> __X2[i] >> __Y2[i];
	for (int i = 0; i < n; i++) { XX.push_back(__X1[i]); XX.push_back(__X2[i]); YY.push_back(__Y1[i]); YY.push_back(__Y2[i]); }
	sort(XX.begin(), XX.end()); sort(YY.begin(), YY.end());
	for (int i = 0; i < XX.size(); i++) { if (i == 0 || XX[i - 1] != XX[i])_XX.push_back(XX[i]); if (i == 0 || YY[i - 1] != YY[i])_YY.push_back(YY[i]); }
	for (int i = 0; i < n; i++) {
		int pos1 = lower_bound(_XX.begin(), _XX.end(), __X1[i]) - _XX.begin(), pos2 = lower_bound(_YY.begin(), _YY.end(), __Y1[i]) - _YY.begin();
		int pos3 = lower_bound(_XX.begin(), _XX.end(), __X2[i]) - _XX.begin(), pos4 = lower_bound(_YY.begin(), _YY.end(), __Y2[i]) - _YY.begin();
		pos1++; pos2++; pos3++; pos4++; __X1[i] = pos1; __Y1[i] = pos2; __X2[i] = pos3; __Y2[i] = pos4; if (__X1[i] > __X2[i])swap(__X1[i], __X2[i]); if (__Y1[i] > __Y2[i])swap(__Y1[i], __Y2[i]);
		if (__X1[i] == __X2[i]) { vec.push_back(make_tuple(__Y1[i], -1LL << 60, __X1[i])); vec.push_back(make_tuple(__Y2[i], 1LL << 60, __X1[i])); }
		else { vec.push_back(make_tuple(__Y1[i], __X1[i], __X2[i])); }
	}sort(vec.begin(), vec.end()); _size = XX.size() + 10;
	for (int i = 0; i < vec.size(); i++) { if (abs(get<1>(vec[i])) >= 1LL << 50)add(get<2>(vec[i]), get<1>(vec[i]) / (-1LL << 60)); else { cnt += __sum(get<1>(vec[i]), get<2>(vec[i])); } }
	cout << cnt << endl;
}