#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   struct edge {     int to, index;     edge(int t = 0, int i = 0) {       to = t;       index = i;     }   };   vector<edge> g[N];   int num[N], ans[N], dep[N], fa[18][N], n, m;   void add(int from, int to, int index) { g[from].push_back(edge(to, index)); }   void dfs(int x, int ffa, int d) {     fa[0][x] = ffa;     dep[x] = d;     for (int i = 0; i < g[x].size(); i++) {       int y = g[x][i].to;       if (y == ffa) continue;       dfs(y, x, d + 1);     }   }   void init() {     m = 0;     while (n >= (1 << m)) m++;     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= n; j++) {         if (fa[i - 1][j] < 0)           fa[i][j] = -1;         else {           fa[i][j] = fa[i - 1][fa[i - 1][j]];         }       }     }   }   int LCA(int x, int y) {     if (dep[x] < dep[y]) swap(x, y);     for (int i = m; i >= 0; i--) {       if ((dep[x] - dep[y]) & (1 << i)) x = fa[i][x];     }     if (x == y) return x;     for (int i = m; i >= 0; i--) {       if (fa[i][x] != fa[i][y]) {         x = fa[i][x];         y = fa[i][y];       }     }     return fa[0][x];   }   void dfs2(int x, int fa, int z) {     for (int i = 0; i < g[x].size(); i++) {       int y = g[x][i].to;       if (y == fa) continue;       dfs2(y, x, g[x][i].index);       num[x] += num[y];     }     ans[z] = num[x];   }   int main() {     int x, y, rt;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d%d , &x, &y);       add(x, y, i);       add(y, x, i);     }     dfs(1, -1, 0);     init();     int TA;     scanf( %d , &TA);     while (TA--) {       scanf( %d%d , &x, &y);       rt = LCA(x, y);       num[x]++;       num[y]++;       num[rt] -= 2;     }     dfs2(1, -1, 0);     for (int i = 1; i < n; i++) printf( %d  , ans[i]);     printf(  n );   }   