func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   vector<int> g[100005];   int dep[100005], f[20][100005], mrk[100005], ans[100005];   map<pair<int, int>, int> mp;   void dfs(int x, int p, int d) {     for (int i = 0; i < g[x].size(); i++)       if (g[x][i] != p) dfs(g[x][i], f[0][g[x][i]] = x, dep[g[x][i]] = d + 1);   }   int dfs2(int x, int p) {     int cnt = 0;     for (int i = 0; i < g[x].size(); i++)       if (g[x][i] != p) {         int num = dfs2(g[x][i], x);         ans[mp[make_pair(x, g[x][i])]] = num;         cnt += num;       }     cnt += mrk[x];     return cnt;   }   int lca(int x, int y) {     if (dep[x] < dep[y]) swap(x, y);     int sub = dep[x] - dep[y];     for (int i = 0; i < 20; i++)       if (sub & (1 << i)) x = f[i][x];     if (x == y) return x;     for (int i = 19; i >= 0; i--)       if (f[i][x] != f[i][y]) {         x = f[i][x];         y = f[i][y];       }     x = f[0][x];     y = f[0][y];     return x;   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       g[x].push_back(y);       g[y].push_back(x);       mp[make_pair(x, y)] = i;       mp[make_pair(y, x)] = i;     }     dfs(1, f[0][1] = 0, dep[1] = 1);     for (int i = 1; i < 20; i++)       for (int j = 1; j <= n; j++) f[i][j] = f[i - 1][f[i - 1][j]];     int q;     scanf( %d , &q);     while (q--) {       int x, y;       scanf( %d%d , &x, &y);       mrk[x]++;       mrk[y]++;       mrk[lca(x, y)] -= 2;     }     dfs2(1, 0);     for (int i = 1; i < n; i++) printf( %d  , ans[i]);     return 0;   }   