func_code_string: #include <bits/stdc++.h>   using std::map;   long long n;   long long p2[100005 * 2] = {1};   long long fa[100005 * 2], size[100005 * 2], p[100005 * 2];   long long vis[100005 * 2];   map<long long, long long> mx, my;   long long cnt;   long long ans = 1;   long long getfa(long long x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]); }   int main() {     scanf( %I64d , &n);     for (long long i = 1; i <= n * 2; i++) {       fa[i] = i;       size[i] = 1;       p2[i] = (p2[i - 1] * 2) % ((int)1e9 + 7);     }     long long x, y, px, py, fx, fy;     for (long long i = 1; i <= n; i++) {       scanf( %I64d %I64d , &x, &y);       if (mx.find(x) == mx.end()) {         mx[x] = ++cnt;       }       if (my.find(y) == my.end()) {         my[y] = ++cnt;       }       px = mx[x];       py = my[y];       fx = getfa(px);       fy = getfa(py);       if (fx == fy) {         p[fx] = 1;       } else {         fa[fx] = fy;         size[fy] += size[fx];         p[fy] |= p[fx];       }       getfa(px);     }     for (long long i = 1; i <= cnt; i++) {       long long fi = getfa(i);       if (vis[fi]) continue;       vis[fi] = 1;       if (p[fi]) {         ans *= p2[size[fi]];       } else {         ans *= (p2[size[fi]] - 1);       }       ans %= ((int)1e9 + 7);     }     printf( %I64d n , ans);   }   