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
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

typedef pair<long long int, long long int> P;
typedef pair<long long int, P> P2;

int N = 300000 - 1; // 必要な数よりも大きい2^nよりも大きい数を入れるとよい
long long int BIT[300000];

void add(int a, long long int w){
	
	// a番目の要素にwを足す O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		BIT[x] += w;
	}
}

long long int sum(int a){
	
	// 1からaまでの要素の合計を返す O(log N)
	
	long long int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += BIT[x];
	}
	return ret;
}

void init(){
	for(int i = 0; i < N; i++){
		BIT[i] = 0;
	}
}

int main(){
	
	int N;
	cin >> N;
	
	vector<P2> v;
	map<long long int, int> mx;
	
	for(int i = 0; i < N; i++){
		long long int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		if(x1 > x2){
			swap(x1, x2);
		}
		if(y1 > y2){
			swap(y1, y2);
		}
		mx[x1] = mx[x2] = 1;
		if(x1 == x2){
			P2 p2;
			p2.first = y1;
			p2.second = make_pair(-INF, x1);
			v.push_back(p2);
			p2.first = y2;
			p2.second = make_pair(INF, x1);
			v.push_back(p2);
		}else{
			P2 p2;
			p2.first = y1;
			p2.second = make_pair(x1, x2);
			v.push_back(p2);
		}
	}
	
	map<long long int, int>::iterator ite;
	
	int cnt = 1;
	for(ite = mx.begin(); ite != mx.end(); ite++){
		ite -> second = cnt;
		cnt++;
	}
	
	sort(v.begin(), v.end());
	init();
	long long int ans = 0;
	
	for(int i = 0; i < v.size(); i++){
		
		int x = mx[v[i].second.second];
		
		if(v[i].second.first == -INF){
			ans -= sum(x);
		}else if(v[i].second.first == INF){
			ans += sum(x);
		}else{
			add(x + 1, -1);
			int x2 = mx[v[i].second.first];
			add(x2, 1);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

