func_code_string: #include <bits/stdc++.h>   using namespace std;   struct edge {     int y, next, id;   };   const int maxn = 100010, maxk = 20;   int n, m, num, head[maxn], depth[maxn], f[maxn][maxk], pre[maxn], ans[maxn],       s[maxn];   edge e[maxn << 1];   inline void add(int a, int b, int id) {     num++;     e[num].next = head[a];     head[a] = num;     e[num].y = b;     e[num].id = id;   }   void dfs(int k, int deep) {     depth[k] = deep;     for (int temp = head[k]; temp >= 0; temp = e[temp].next) {       int j = e[temp].y;       if (j != f[k][0]) {         pre[j] = e[temp].id;         f[j][0] = k;         int i = 0;         for (int i = 0; f[f[j][i]][i] > 0; i++) f[j][i + 1] = f[f[j][i]][i];         dfs(j, deep + 1);       }     }   }   inline int LCA(int a, int b) {     if (depth[a] < depth[b]) swap(a, b);     for (int i = 17; depth[a] > depth[b]; i--)       if (f[a][i] > 0 && depth[f[a][i]] >= depth[b]) a = f[a][i];     if (a == b) return a;     for (int i = 17; f[a][0] != f[b][0]; i--)       if (f[a][i] > 0 && f[a][i] != f[b][i]) {         a = f[a][i];         b = f[b][i];       }     return f[a][0];   }   void slove(int k) {     for (int temp = head[k]; temp >= 0; temp = e[temp].next) {       int j = e[temp].y;       if (j != f[k][0]) {         slove(j);         s[k] += s[j];       }     }     if (k > 1) ans[pre[k]] = s[k];   }   int main() {     scanf( %d , &n);     memset(head, -1, sizeof(head));     num = -1;     for (int i = 1; i < n; i++) {       int a, b;       scanf( %d%d , &a, &b);       add(a, b, i);       add(b, a, i);     }     memset(f, -1, sizeof(f));     dfs(1, 0);     scanf( %d , &m);     memset(ans, 0, sizeof(ans));     for (int i = 0; i < m; i++) {       int a, b;       scanf( %d%d , &a, &b);       int lca = LCA(a, b);       s[a]++;       s[b]++;       s[lca] -= 2;     }     slove(1);     for (int i = 1; i < n; i++) printf( %d  , ans[i]);     printf(  n );     return 0;   }   