Codeforces Round 440 (Div. 1, based on Technocup 2018 Elimination Round 2)
C
Points, Lines and Ready-made Titles
Codeforces
未评级
原题
← BD →
翻译中…

You are given $*n*$ distinct points on a plane with integral coordinates. For each point you can either draw a vertical line through it, draw a horizontal line through it, or do nothing.

翻译中…

You consider several coinciding straight lines as a single one. How many distinct pictures you can get? Print the answer modulo $10^{9} + 7$.

翻译中…

Input

翻译中…

The first line contains single integer $*n*$ ($1 ≤ *n* ≤ 10^{5}$) — the number of points.

翻译中…

$*n*$ lines follow. The ($*i* + 1$)-th of these lines contains two integers $*x*_{*i*}$, $*y*_{*i*}$ ($- 10^{9} ≤ *x*_{*i*}, *y*_{*i*} ≤ 10^{9}$) — coordinates of the $*i*$-th point.

翻译中…

It is guaranteed that all points are distinct.

翻译中…

Output

翻译中…

Print the number of possible distinct pictures modulo $10^{9} + 7$.

翻译中…

Note

翻译中…

In the first example there are two vertical and two horizontal lines passing through the points. You can get pictures with any subset of these lines. For example, you can get the picture containing all four lines in two ways (each segment represents a line containing it).

翻译中…

The first way: image The second way: image

翻译中…

In the second example you can work with two points independently. The number of pictures is $3^{2} = 9$.

翻译中…

样例

Input #1
4
1 1
1 2
2 1
2 2
Output #1
16
InputCopy OutputCopy
Input #2
2
-1 -1
0 1
Output #2
9
InputCopy OutputCopy
题目信息
题号
871C
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。