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<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))
#define x1 _____x1
#define x2 _____x2
#define y1 _____y1
#define y2 _____y2
Int n;

class Compressor{
public:
  vector<Int> dict;
  Compressor(){}
  void add(Int x){
    dict.push_back(x);
  }
  void compress(){
    sort(dict.begin(), dict.end());
    dict.erase(unique(dict.begin(), dict.end()), dict.end());
  }
  int convert(Int x){
    return lower_bound(dict.begin(), dict.end(), x) - dict.begin();
  }
  Int& operator[](int index)
  {
    return dict[index];
  }
};

void add(vector<int> &bit, int ind, int val){
  ind++;
  while(ind < bit.size()){
    bit[ind] += val;
    ind += ind & -ind;
  }
}

Int sum(vector<int> &bit, int ind){
  ind++;
  Int res = 0;
  while(ind){
    res += bit[ind];
    ind -= ind & -ind;
  }
  return res;
}

Compressor comp;
vector<P> cnt[324000], query[324000];
Int x1[108000], x2[108000], y1[108000], y2[108000];
int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    comp.add(x1[i]);
    comp.add(y1[i]);
    comp.add(x2[i]);
    comp.add(y2[i]);
  }
  comp.add(-INF);
  comp.compress();
  for(int i = 0;i < n;i++){
    x1[i] = comp.convert(x1[i]);
    x2[i] = comp.convert(x2[i]);
    y1[i] = comp.convert(y1[i]);
    y2[i] = comp.convert(y2[i]);
    if(x1[i] == x2[i]){
      if(y1[i] > y2[i])swap(y1[i], y2[i]);
      query[y1[i]].push_back(P(x1[i], 1));
      query[y2[i]].push_back(P(x1[i], -1));
    }
    if(y1[i] == y2[i]){
      if(x1[i] > x2[i])swap(x1[i], x2[i]);
      cnt[y1[i]].push_back(P(x1[i], x2[i]));
    }
  }
  vector<int> bit(n*3, 0);
  Int res = 0;
  for(int i = 0;i < n*3;i++){
    for(auto q:query[i]){
      if(q.second == 1)add(bit, q.first, 1);
    }
    for(auto q:cnt[i]){
      res += sum(bit, q.second) - sum(bit, q.first - 1);
    }
    for(auto q:query[i]){
      if(q.second == -1)add(bit, q.first, -1);
    }
  }
  cout << res << endl;
  return 0;
}
