func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Arc {     int f, s, prev;   } arr[400005];   Arc nbr[400005];   Arc br[400005];   int beg[400005];   int kol = 0;   void add_arc(int f, int s) {     arr[kol].f = f;     arr[kol].s = s;     arr[kol].prev = beg[f];     beg[f] = kol++;     arr[kol].f = s;     arr[kol].s = f;     arr[kol].prev = beg[s];     beg[s] = kol++;   }   int pos[1 << 19];   int lev[1 << 19];   int llv[1 << 19];   int tin[1 << 19];   int tout[1 << 19];   int base[1 << 19];   int t = 0, ff = 0, q = 0;   void DFS(int v, int p = -1) {     tout[v] = tin[v] = ++t;     for (int i = beg[v]; i != -1; i = arr[i].prev) {       if (arr[i].s != p) {         if (!tin[arr[i].s]) {           DFS(arr[i].s, v);           if (tout[arr[i].s] <= tin[v]) {             tout[v] = min(tout[v], tout[arr[i].s]);             nbr[ff++] = arr[i];           } else {             br[q++] = arr[i];           }         } else {           tout[v] = min(tout[v], tout[arr[i].s]);         }       }     }   }   void DFS2(int v, int lv = 0, int p = -1) {     tin[v] = t;     llv[v] = lv;     lev[t] = lv;     pos[t++] = v;     for (int i = beg[v]; i != -1; i = arr[i].prev) {       if (arr[i].s != p) {         DFS2(arr[i].s, lv + 1, v);         lev[t] = lv;         pos[t++] = v;       }     }   }   int get_base(int v) {     if (base[v] == v) {       return v;     } else {       return base[v] = get_base(base[v]);     }   }   void merge_base(int a, int b) {     if (rand() & 1) {       base[get_base(a)] = get_base(b);     } else {       base[get_base(b)] = get_base(a);     }   }   void build_tree() {     for (int i = (1 << 18) - 1; i; --i) {       if (lev[i + i] < lev[i + i + 1]) {         lev[i] = lev[i + i];         pos[i] = pos[i + i];       } else {         lev[i] = lev[i + i + 1];         pos[i] = pos[i + i + 1];       }     }   }   int get_min(int l, int r) {     l = tin[l];     r = tin[r];     if (l > r) {       swap(l, r);     }     ++r;     int best = lev[l], bv = pos[l];     while (r - l > 1) {       if (!(l & 1)) {         if (lev[l + 1] < best) {           best = lev[l + 1];           bv = pos[l + 1];         }       }       if (r & 1) {         if (lev[r - 1] < best) {           best = lev[r - 1];           bv = pos[r - 1];         }       }       l >>= 1;       r >>= 1;     }     return bv;   }   int main() {     memset(beg, -1, sizeof beg);     int n, m, k;     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) {       int f, s;       scanf( %d%d , &f, &s);       --f;       --s;       add_arc(f, s);     }     DFS(0);     for (int i = 0; i < n; ++i) {       base[i] = i;     }     for (int i = 0; i < ff; ++i) {       merge_base(nbr[i].s, nbr[i].f);     }     memset(beg, -1, sizeof beg);     memset(tin, -1, sizeof tin);     for (int i = 0; i < q; ++i) {       add_arc(get_base(br[i].f), get_base(br[i].s));     }     t = 1 << 18;     DFS2(get_base(0));     build_tree();     scanf( %d , &k);     for (int i = 0; i < k; ++i) {       int f, s;       scanf( %d%d , &f, &s);       --f;       --s;       f = get_base(f);       s = get_base(s);       int ret = llv[f] + llv[s] - 2 * llv[get_min(f, s)];       printf( %d n , ret);     }     return 0;   }   