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 <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(a*x, a*y); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;
typedef vector <Vector> Polygon;

class Segment {
 public:
  Point p1, p2;

  Segment(Point p1 = Point(), Point p2 = Point()): p1(p1), p2(p2) {}
};

double norm(Vector a) {
  return a.x*a.x+a.y*a.y;
}

double abs(Vector a) {
  return sqrt(norm(a));
}

#define BOTTOM 0
#define LEFT 1
#define RIGHT 2
#define TOP 3

class EndPoint {
 public:
  Point p;
  int seg, st;
  EndPoint() {}
  EndPoint(Point p, int seg, int st): p(p), seg(seg), st(st) {}

  bool operator < (const EndPoint &ep) const {
    if (p.y == ep.p.y) {
      return st < ep.st;
    }else return p.y < ep.p.y;
  }
};

// MAX_N:???????????°
#define MAX_N 100000
// MAX_P:??§?¨?????????§???(??¶??????)
#define MAX_P 1000000000
EndPoint EP[2*MAX_N];

// ??????????????????: ????????????????????????
int manhattanIntersection(vector<Segment> s) {
  int n = s.size();

  for (int i = 0, k = 0; i < n; i++) {
    if (s[i].p1.y == s[i].p2.y) {
      if (s[i].p1.x > s[i].p2.x) swap(s[i].p1, s[i].p2);
    }else if (s[i].p1.y > s[i].p2.y) {
      swap(s[i].p1, s[i].p2);
    }
    if (s[i].p1.y == s[i].p2.y) {
      EP[k++] = EndPoint(s[i].p1, i, LEFT);
      EP[k++] = EndPoint(s[i].p2, i, RIGHT);
    }else {
      EP[k++] = EndPoint(s[i].p1, i, BOTTOM);
      EP[k++] = EndPoint(s[i].p2, i, TOP);
    }
  }

  sort(EP, EP+(2*n));

  set<int> BT;
  BT.insert(MAX_P+1);
  int cnt = 0;

  for (int i = 0; i < 2*n; i++) {
    if (EP[i].st == TOP) {
      BT.erase(EP[i].p.x);
    }else if (EP[i].st == BOTTOM) {
      BT.insert(EP[i].p.x);
    }else if (EP[i].st == LEFT) {
      set<int>::iterator b = lower_bound(BT.begin(), BT.end(), s[EP[i].seg].p1.x);
      set<int>::iterator e = upper_bound(BT.begin(), BT.end(), s[EP[i].seg].p2.x);
      cnt += distance(b, e);
    }
  }

  return cnt;
}

int main() {
  int n;
  cin >> n;
  vector<Segment> p;
  for (int i = 0; i < n; i++) {
    Segment l;
    cin >> l.p1.x >> l.p1.y >> l.p2.x >> l.p2.y;
    p.push_back(l);
  }
  cout << manhattanIntersection(p) << endl;
}