func_code_string: #include <bits/stdc++.h>   using namespace std;   const long double PI = 3.14159265359;   const long long MOD = (long long)1e9 + 7;   const long long MAXN = (long long)1e5 + 10;   const long long INF = (long long)9223372036854775;   const long double EPS = (long double)1e-8;   long long par[MAXN], sz[MAXN], ln[MAXN], pw[MAXN];   pair<pair<long long, long long>, long long> a[MAXN];   long long get_par(long long node) {     if (node == par[node]) return node;     par[node] = get_par(par[node]);     return par[node];   }   void merge(long long a, long long b) {     long long x = get_par(a);     long long y = get_par(b);     if (x == y) return;     ln[y] += ln[x];     sz[y] += sz[x];     par[x] = y;   }   bool CMPx(pair<pair<long long, long long>, long long> a,             pair<pair<long long, long long>, long long> b) {     return a.first.first < b.first.first;   }   bool CMPy(pair<pair<long long, long long>, long long> a,             pair<pair<long long, long long>, long long> b) {     return a.first.second < b.first.second;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     for (int i = 0; i < MAXN; i++) par[i] = i;     pw[0] = 1;     for (int i = 1; i < MAXN; i++) pw[i] = (pw[i - 1] * 2ll) % MOD;     fill(sz, sz + MAXN, 1);     long long n;     scanf( %lld , &n);     for (int i = 0; i < n; i++) {       scanf( %lld%lld , &a[i].first.first, &a[i].first.second);       a[i].second = i;     }     sort(a, a + n, CMPx);     ln[get_par(a[0].second)]++;     for (int i = 1; i < n; i++) {       if (a[i].first.first == a[i - 1].first.first) {         merge(a[i].second, a[i - 1].second);       } else {         ln[get_par(a[i].second)]++;       }     }     sort(a, a + n, CMPy);     ln[get_par(a[0].second)]++;     for (int i = 1; i < n; i++) {       if (a[i].first.second == a[i - 1].first.second) {         merge(a[i].second, a[i - 1].second);       } else {         ln[get_par(a[i].second)]++;       }     }     long long ans = 1;     for (int i = 0; i < n; i++) {       if (par[i] == i) {         if (ln[i] <= sz[i]) {           ans *= pw[ln[i]];         } else {           ans *= (pw[ln[i]] - 1);         }         ans %= MOD;       }     }     printf( %lld , ans);     return 0;   }   