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
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=400100,Mx=200000;
int n,m,c[N],o1[N],o2[N],tot1,tot2;
struct line{int x1,y1,x2,y2;}Line[N];
struct node{int x,y,opt;}p[N];
struct hx{int x1,x2,y;}h[N];
bool operator<(const node a,const node b){return a.y<b.y;}
bool operator<(const hx a,const hx b){return a.y<b.y;}
int lowbit(int x){return x&(-x);}
void Add(int x,int d){while(x<=Mx){c[x]+=d;x+=lowbit(x);}}
int query(int x){int ret=0;while(x){ret+=c[x];x-=lowbit(x);}return ret;}
int query(int l,int r){return query(r)-query(l-1);}
int main(){
	int all=gi();
	for(int i=1;i<=all;i++){
		int x1=gi(),y1=gi(),x2=gi(),y2=gi();
		Line[i]=(line){x1,y1,x2,y2};
		o1[++tot1]=x1;o1[++tot1]=x2;
		o2[++tot2]=y1;o2[++tot2]=y2;
	}
	sort(o1+1,o1+tot1+1);tot1=unique(o1+1,o1+tot1+1)-o1-1;
	sort(o2+1,o2+tot2+1);tot2=unique(o2+1,o2+tot2+1)-o2-1;
	for(int i=1;i<=all;i++){
		Line[i].x1=lower_bound(o1+1,o1+tot1+1,Line[i].x1)-o1;
		Line[i].x2=lower_bound(o1+1,o1+tot1+1,Line[i].x2)-o1;
		Line[i].y1=lower_bound(o2+1,o2+tot2+1,Line[i].y1)-o2;
		Line[i].y2=lower_bound(o2+1,o2+tot2+1,Line[i].y2)-o2;
	}
	for(int i=1;i<=all;i++){
		int x1=Line[i].x1,y1=Line[i].y1,x2=Line[i].x2,y2=Line[i].y2;
		if(x1==x2){
			if(y1>y2)swap(y1,y2);
			p[++m]=(node){x1,y1,1};p[++m]=(node){x1,y2+1,-1};
		}
		else{
			if(x1>x2)swap(x1,x2);
			h[++n]=(hx){x1,x2,y1};
		}
	}
	sort(h+1,h+n+1);sort(p+1,p+m+1);int pos=1,ans=0;
	for(int i=1;i<=n;i++){
		while(pos<=m && p[pos].y<=h[i].y){Add(p[pos].x,p[pos].opt);pos++;}
		ans+=query(h[i].x1,h[i].x2);
	}
	printf("%d\n",ans);
	return 0;
}

