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 "inspect.hpp"
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
  
int main(){
	vector<pair<int,pair<int,int>>> vx,vy;
	int i=0,r=0,n,x1,y1,x2,y2;
	for(scanf("%d",&n);i<n;i++){
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(x1>x2)swap(x1,x2);
		if(y1>y2)swap(y1,y2);
		if(x1==x2)vy.emplace_back(make_pair(x1,make_pair(y1,y2)));
		else vx.emplace_back(make_pair(y1,make_pair(x1,x2)));
	}
	//sort(vx.begin(),vx.end());
	sort(vy.begin(),vy.end());
	for(auto &e:vx){
		auto it1=lower_bound(vy.begin(),vy.end(),make_pair(e.second.first,make_pair(-2000000000,-2000000000)));
		auto it2=lower_bound(vy.begin(),vy.end(),make_pair(e.second.second+1,make_pair(-2000000000,-2000000000)));
		
		for(;it1!=it2;++it1){
			auto &f=*it1;
			if(f.second.first<=e.first&&e.first<=f.second.second)r++;
		}
	}
	printf("%d\n",r);
}