PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000061. Hình chữ nhật không có cạnh trên (Tokitsukaze and Strange Rectangle)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

2 lộ trình

Hình chữ nhật không có cạnh trên (Tokitsukaze and Strange Rectangle)

Tokitsukaze and Strange Rectangle

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn distinct points. Choose real numbers l<rl<r and aa and select precisely the points with l<xi<rl<x_i<r and yi>ay_i>a. The selected region has no upper boundary. Count the distinct nonempty selected sets, counting identical sets only once.

Input

The first line contains nn. The next nn lines give point coordinates xi,yix_i,y_i.

Output

Print the number of distinct nonempty point sets obtainable.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le20; 1≤xi,yi≤1091\le x_i,y_i\le10^9; all point pairs (xi,yi)(x_i,y_i) are distinct.
  • Subtask 2 (30 points): 1≤n≤15001\le n\le1500; 1≤xi,yi≤1091\le x_i,y_i\le10^9; all point pairs (xi,yi)(x_i,y_i) are distinct.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le200000; 1≤xi,yi≤1091\le x_i,y_i\le10^9; all point pairs (xi,yi)(x_i,y_i) are distinct.

Examples

Input

4
2 1
2 2
3 1
3 2

Output

6

Explanation

There are 2 selected sets of size one, 3 of size two, and 1 of size four. No set of three points is obtainable, so the answer is 6.