func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 505;   const int maxm = 1e4 + 5;   struct node {     int pre[maxn];     void init() {       for (int i = 0; i < maxn; ++i) {         pre[i] = i;       }     }     int Find(int x) {       if (x != pre[x]) pre[x] = Find(pre[x]);       return pre[x];     }     void v(int x, int y) {       int fx = Find(x), fy = Find(y);       if (fx != fy) pre[fy] = fx;     }   };   struct node q[maxm], h[maxm];   int u[maxm], v[maxm];   int n, m;   int solve(node a, node b) {     int ans = 0;     for (int i = 1; i <= n; ++i) {       a.v(i, b.Find(i));     }     for (int i = 1; i <= n; ++i) {       if (a.Find(i) == i) ans++;     }     return ans;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) scanf( %d%d , &u[i], &v[i]);     q[0].init();     h[m + 1].init();     for (int i = 1; i <= m; ++i) {       q[i] = q[i - 1];       q[i].v(u[i], v[i]);     }     for (int i = m; i >= 1; --i) {       h[i] = h[i + 1];       h[i].v(u[i], v[i]);     }     int tt;     scanf( %d , &tt);     while (tt--) {       int x, y;       scanf( %d%d , &x, &y);       printf( %d n , solve(q[x - 1], h[y + 1]));     }     return 0;   }   