{"raw_statement":[{"iden":"statement","content":"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.\n\nYou consider several coinciding straight lines as a single one. How many distinct pictures you can get? Print the answer modulo 109 + 7."},{"iden":"input","content":"The first line contains single integer _n_ (1 ≤ _n_ ≤ 105) — the number of points.\n\n_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.\n\nIt is guaranteed that all points are distinct."},{"iden":"output","content":"Print the number of possible distinct pictures modulo 109 + 7."},{"iden":"examples","content":"Input\n\n4\n1 1\n1 2\n2 1\n2 2\n\nOutput\n\n16\n\nInput\n\n2\n-1 -1\n0 1\n\nOutput\n\n9"},{"iden":"note","content":"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).\n\n<center>The first way: ![image](https://espresso.codeforces.com/28988446ba734d5927d35c1ff2a90c0ca420c50d.png) The second way: ![image](https://espresso.codeforces.com/dfc652613496b66ba02da6b8aefcd06bd640ece8.png)</center>In the second example you can work with two points independently. The number of pictures is 32 = 9."}],"translated_statement":[{"iden":"statement","content":"给定平面上 n 个横纵坐标均为整数的互不相同的点。对于每个点，你可以选择：过该点画一条竖直线，过该点画一条水平线，或什么都不做。\n\n你将重合的直线视为同一条。问你能得到多少种不同的图案？请对 10^9 + 7 取模。\n\n第一行包含一个整数 n (1 ≤ n ≤ 10^5) —— 点的数量。\n\n接下来 n 行，第 (i + 1) 行包含两个整数 x_i, y_i ( - 10^9 ≤ x_i, y_i ≤ 10^9) —— 第 i 个点的坐标。\n\n保证所有点互不相同。\n\n请输出可能的不同图案数量，对 10^9 + 7 取模。\n\n在第一个例子中，有两条竖直线和两条水平线经过这些点。你可以得到任意这些线的子集构成的图案。例如，包含全部四条线的图案可以通过两种方式得到（每条线段代表包含它的直线）。\n\n在第二个例子中，你可以独立处理两个点。图案的数量是 3^2 = 9。"},{"iden":"input","content":"第一行包含一个整数 n (1 ≤ n ≤ 10^5) —— 点的数量。n 行follow。第 (i + 1) 行包含两个整数 x_i, y_i ( - 10^9 ≤ x_i, y_i ≤ 10^9) —— 第 i 个点的坐标。保证所有点互不相同。"},{"iden":"output","content":"请输出可能的不同图案数量，对 10^9 + 7 取模。"},{"iden":"examples","content":"输入\n4\n1 1\n1 2\n2 1\n2 2\n输出\n16\n\n输入\n2\n-1 -1\n0 1\n输出\n9"},{"iden":"note","content":"在第一个例子中，有两条竖直线和两条水平线经过这些点。你可以得到任意这些线的子集构成的图案。例如，包含全部四条线的图案可以通过两种方式得到（每条线段代表包含它的直线）。第一种方式：      第二种方式：      在第二个例子中，你可以独立处理两个点。图案的数量是 3^2 = 9。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of distinct points.  \nLet $ P = \\{(x_i, y_i) \\mid i \\in \\{1, \\dots, n\\}\\} $ be the set of points with integer coordinates, all distinct.  \n\nFor each point $ (x_i, y_i) $, we choose one of three actions:  \n- Draw a vertical line at $ x = x_i $,  \n- Draw a horizontal line at $ y = y_i $,  \n- Do nothing.  \n\nLet $ V = \\{x_i \\mid \\text{vertical line drawn through } (x_i, y_i)\\} $ be the set of distinct vertical lines.  \nLet $ H = \\{y_i \\mid \\text{horizontal line drawn through } (x_i, y_i)\\} $ be the set of distinct horizontal lines.  \n\nA *picture* is defined by the pair $ (V, H) $, where coinciding lines are merged.  \n\n**Constraints**  \n1. $ 1 \\leq n \\leq 10^5 $  \n2. $ -10^9 \\leq x_i, y_i \\leq 10^9 $ for all $ i $  \n3. All points in $ P $ are distinct.  \n\n**Objective**  \nCompute the number of distinct pictures $ (V, H) $ achievable under the above choices, modulo $ 10^9 + 7 $.","simple_statement":null,"has_page_source":false}