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

#FT0000155. Những điểm nằm trong hình chữ nhật bao (Enclosed Points)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Những điểm nằm trong hình chữ nhật bao (Enclosed Points)

Enclosed Points

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

You are given nn planar points with pairwise distinct xx-coordinates and pairwise distinct yy-coordinates. For every nonempty subset TT of the point set SS, form the smallest axis-aligned rectangle containing all points of TT. Let f(T)f(T) be the number of points from the entire set SS inside or on the boundary of this rectangle; these points need not belong to TT. Compute ∑∅≠T⊆Sf(T)\sum_{\varnothing\ne T\subseteq S}f(T) modulo 998244353998244353.

Input

The first line contains nn. Each of the next nn lines gives xi,yix_i,y_i.

Output

Print the required sum modulo 998244353998244353.

Subtasks

  • Subtask 1 (20 points): 1≤n≤91\le n\le 9; For all i≠ji\ne j, xi≠xjx_i\ne x_j and yi≠yjy_i\ne y_j; −109≤xi,yi≤109-10^9\le x_i,y_i\le10^9.
  • Subtask 2 (30 points): 1≤n≤30001\le n\le 3000; For all i≠ji\ne j, xi≠xjx_i\ne x_j and yi≠yjy_i\ne y_j; −109≤xi,yi≤109-10^9\le x_i,y_i\le10^9.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000; For all i≠ji\ne j, xi≠xjx_i\ne x_j and yi≠yjy_i\ne y_j; −109≤xi,yi≤109-10^9\le x_i,y_i\le10^9.

Examples

Example 1

Input

3
-1 3
2 1
3 -2

Output

13

Explanation

There are seven nonempty subsets. The three singletons each give f=1f=1; the three pairs give f=2,2,3f=2,2,3; the full set gives f=3f=3. Thus the sum is 1313.

Example 2

Input

1
0 0

Output

1

Explanation

Only the singleton subset exists; its degenerate bounding rectangle contains one point, so the sum is 1.