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 109 + 7.
## Input
The first line contains single integer _n_ (1 ≤ _n_ ≤ 105) — the number of points.
_n_ lines follow. The (_i_ + 1)-th of these lines contains two integers _x__i_, _y__i_ ( - 109 ≤ _x__i_, _y__i_ ≤ 109) — coordinates of the _i_\-th point.
It is guaranteed that all points are distinct.
## Output
Print the number of possible distinct pictures modulo 109 + 7.
[samples]
## 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).
<center>The first way:  The second way: </center>In the second example you can work with two points independently. The number of pictures is 32 = 9.
给定平面上 #cf_span[n] 个坐标为整数的互不相同的点。对于每个点,你可以选择:过该点画一条竖直线、过该点画一条水平线,或什么都不做。
你将重合的直线视为同一条。请问你能得到多少种不同的图案?请对 #cf_span[109 + 7] 取模输出。
第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 105]) —— 点的数量。
接下来 #cf_span[n] 行,第 (#cf_span[i + 1]) 行包含两个整数 #cf_span[xi], #cf_span[yi] (#cf_span[ - 109 ≤ xi, yi ≤ 109]) —— 第 #cf_span[i] 个点的坐标。
保证所有点互不相同。
请输出可能的不同图案数量,对 #cf_span[109 + 7] 取模。
在第一个例子中,有两条竖直线和两条水平线经过这些点。你可以得到这些线的任意子集构成的图案。例如,包含全部四条线的图案可以通过两种方式得到(每条线段代表包含它的直线)。
在第二个例子中,你可以独立处理两个点。图案数量为 #cf_span[32 = 9]。
## Input
第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 105]) —— 点的数量。#cf_span[n] 行follow。第 (#cf_span[i + 1]) 行包含两个整数 #cf_span[xi], #cf_span[yi] (#cf_span[ - 109 ≤ xi, yi ≤ 109]) —— 第 #cf_span[i] 个点的坐标。保证所有点互不相同。
## Output
请输出可能的不同图案数量,对 #cf_span[109 + 7] 取模。
[samples]
## Note
在第一个例子中,有两条竖直线和两条水平线经过这些点。你可以得到这些线的任意子集构成的图案。例如,包含全部四条线的图案可以通过两种方式得到(每条线段代表包含它的直线)。第一种方式: 第二种方式: 在第二个例子中,你可以独立处理两个点。图案数量为 #cf_span[32 = 9]。
**Definitions**
Let $ n \in \mathbb{Z}^+ $ be the number of distinct points.
Let $ P = \{(x_i, y_i) \mid i \in \{1, \dots, n\}\} $ be the set of points with integer coordinates.
Let $ V = \{x \mid \exists y, (x, y) \in P\} $ be the set of distinct x-coordinates.
Let $ H = \{y \mid \exists x, (x, y) \in P\} $ be the set of distinct y-coordinates.
For each point $ (x_i, y_i) $, we choose one of three actions:
- Draw the vertical line $ x = x_i $,
- Draw the horizontal line $ y = y_i $,
- Draw nothing.
Two pictures are identical if they contain the same set of lines (coinciding lines are not counted multiple times).
**Constraints**
1. $ 1 \leq n \leq 10^5 $
2. $ -10^9 \leq x_i, y_i \leq 10^9 $
3. All points in $ P $ are distinct.
**Objective**
Count the number of distinct subsets of lines (vertical and/or horizontal) that can be formed, where for each point $ (x_i, y_i) $, at least one of its associated lines (vertical or horizontal) may be chosen, but not both unless forced by another point.
Define a bipartite graph $ G = (V \cup H, E) $, where each point $ (x_i, y_i) $ corresponds to an edge between $ x_i \in V $ and $ y_i \in H $.
Each edge (point) independently chooses to activate its incident vertical line, its incident horizontal line, or neither — but the resulting picture is determined by the *set* of activated lines.
The number of distinct pictures equals the product over all connected components $ C $ of $ G $ of $ (2^{v_C} + 2^{h_C} - 1) $, where:
- $ v_C = |V \cap C| $, the number of distinct x-coordinates in component $ C $,
- $ h_C = |H \cap C| $, the number of distinct y-coordinates in component $ C $.
Thus, the answer is:
$$
\prod_{C \in \text{components of } G} \left(2^{|V_C|} + 2^{|H_C|} - 1\right) \mod (10^9 + 7)
$$