func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   const int maxm = 100005 * 2;   const int maxn = 100005;   const int mod = 1000000007;   struct Edge {     int v, next;   } E[maxm];   struct sw {     int v, next;   } EE[maxm];   int head[maxn], ind;   int headd[maxn], indd;   int dfs[maxn], low[maxn], clo;   int bri, cou, S[maxn], hi;   int n, m;   int f[maxn], have[maxn];   void add(int u, int v) {     E[ind].v = v, E[ind].next = head[u], head[u] = ind++;     E[ind].v = u, E[ind].next = head[v], head[v] = ind++;   }   void add1(int u, int v) {     EE[indd].v = v, EE[indd].next = headd[u], headd[u] = indd++;     EE[indd].v = u, EE[indd].next = headd[v], headd[v] = indd++;   }   void init() {     memset(head, -1, sizeof(head));     memset(headd, -1, sizeof(headd));     memset(dfs, -1, sizeof(dfs));     memset(low, -1, sizeof(low));     clo = ind = indd = 0;   }   vector<int> vvv[maxn];   void tarjan(int u, int id) {     dfs[u] = low[u] = clo++;     S[hi++] = u;     for (int i = head[u]; ~i; i = E[i].next) {       if (i == (id ^ 1)) continue;       int v = E[i].v;       if (dfs[v] == -1) {         tarjan(v, i);         low[u] = min(low[u], low[v]);         if (dfs[u] < low[v]) {           bri++;           vvv[u].push_back(v);         }       } else         low[u] = min(low[u], dfs[v]);     }     if (dfs[u] == low[u]) {       int v;       do {         v = S[--hi];         f[v] = u;         for (int j = 0; j < vvv[v].size(); j++) {           int pa = f[vvv[v][j]];           add1(u, pa);         }         have[u]++;       } while (u != v);     }   }   void work() {     hi = 0;     for (int i = 1; i <= n; i++)       if (dfs[i] == -1) {         tarjan(i, -1);       }   }   int ff[maxn][18], lev;   int dep[maxn];   long long dis[maxn];   int LCA(int x, int y) {     if (dep[x] > dep[y]) x = x ^ y, y = x ^ y, x = x ^ y;     for (int i = lev; i >= 0; i--)       if (dep[y] - dep[x] >> i & 1) y = ff[y][i];     if (x == y) return x;     for (int i = lev; i >= 0; i--)       if (ff[x][i] != ff[y][i]) x = ff[x][i], y = ff[y][i];     return ff[x][0];   }   void done(int u, int p) {     dep[u] = dep[p] + 1;     if (have[u] > 1)       dis[u] = dis[p] * 2 % mod;     else       dis[u] = dis[p];     ff[u][0] = p;     int v;     for (int i = headd[u]; ~i; i = EE[i].next) {       v = EE[i].v;       if (v != p) {         done(v, u);       }     }   }   void initLca() {     dis[0] = 1;     done(1, 0);     lev = 1;     for (; (1 << lev) <= n; lev++)       for (int i = 0; i <= n; i++)         if (f[i] == i) ff[i][lev] = ff[ff[i][lev - 1]][lev - 1];     lev--;   }   long long extend_gcd(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1, y = 0;       return a;     }     long long gcd = extend_gcd(b, a % b, x, y);     long long t = x;     x = y;     y = t - a / b * x;     return gcd;   }   long long Get_Inverse(long long num) {     long long x, y;     extend_gcd(num, 1000000007, x, y);     return (x % 1000000007 + 1000000007) % 1000000007;   }   int main(void) {     while (~scanf( %d%d , &n, &m)) {       init();       while (m--) {         int u, v;         scanf( %d%d , &u, &v);         add(u, v);       }       work();       initLca();       int k, a, b, fa, fb, pa;       scanf( %d , &k);       for (int i = 0; i < k; i++) {         scanf( %d%d , &a, &b);         fa = f[a];         fb = f[b];         long long ans = dis[fa] * dis[fb] % mod;         pa = LCA(fa, fb);         int need = (have[pa] > 1 ? 2 : 1);         ans = ans * Get_Inverse(dis[pa]) % mod;         ans = ans * (Get_Inverse(dis[pa] * Get_Inverse(need) % mod)) % mod;         printf( %I64d n , ans);       }     }     return 0;   }   