func_code_string: #include <bits/stdc++.h>   using namespace std;   long long t, n, i, j, k, x, y, z, ans, l, r, mid, s, q;   long long a[100005], b[100005], c[100005], d[100005], p[100005], dp[100005][20];   vector<long long> v[100005], u[100005];   map<pair<int, int>, int> m;   void dfs(int x, int y, int z) {     dp[x][0] = y;     d[x] = z;     p[x] = y;     u[z].push_back(x);     for (int i = 0; i < v[x].size(); i++)       if (v[x][i] != y) dfs(v[x][i], x, z + 1);   }   int lca(int x, int y) {     if (d[x] < d[y]) swap(x, y);     for (int i = 18; i >= 0; i--)       if (d[x] - (1 << i) >= d[y]) x = dp[x][i];     if (x == y) return x;     for (int i = 18; i >= 0; i--)       if (dp[x][i] != dp[y][i]) {         x = dp[x][i];         y = dp[y][i];       }     return dp[x][0];   }   void build() {     dfs(1, 0, 0);     for (i = 1; i <= 18; i++)       for (j = 1; j <= n; j++) dp[j][i] = dp[dp[j][i - 1]][i - 1];   }   int main() {     ios::sync_with_stdio(NULL);     cin.tie(0);     cout.tie(0);     cin >> n;     for (i = 1; i < n; i++) {       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);       b[i] = x;       c[i] = y;       m[{x, y}] = m[{y, x}] = i;     }     build();     cin >> q;     for (i = 0; i < q; i++) {       cin >> x >> y;       if (d[x] < d[y]) swap(x, y);       z = lca(x, y);       a[x]++;       a[y]++;       a[z] -= 2;     }     for (i = 100000; i > 0; i--)       for (j = 0; j < u[i].size(); j++) {         x = u[i][j];         m[{x, p[x]}] = m[{p[x], x}] = a[x];         a[p[x]] += a[x];       }     for (i = 1; i < n; i++) cout << m[{b[i], c[i]}] <<    ;   }   