#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 50;   int n, q;   int lca[N][25], mark[N], sum[N], h[N], a[N][4];   vector<int> adj[N];   map<int, map<int, int> > m;   void DFS(int v, int p, int hi) {     h[v] = hi;     lca[v][0] = p;     for (auto u : adj[v]) {       if (u == p) continue;       DFS(u, v, hi + 1);     }   }   void dfs_sum(int v, int p) {     sum[v] += mark[v];     for (auto u : adj[v]) {       if (u == p) continue;       dfs_sum(u, v);       sum[v] += sum[u];     }     m[p][v] = sum[v];   }   void LCA() {     for (int j = 1; j <= 20; j++)       for (int i = 1; i <= n; i++) lca[i][j] = lca[lca[i][j - 1]][j - 1];   }   int find_par(int v, int k) {     for (int j = 0; j <= 20; j++) {       if (k & (1 << j)) v = lca[v][j];     }     return v;   }   int find_lca(int u, int v) {     v = find_par(v, h[v] - h[u]);     if (v == u) return u;     for (int j = 20; j >= 0; j--) {       if (lca[u][j] != lca[v][j]) {         u = lca[u][j];         v = lca[v][j];       }     }     return lca[u][0];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie();     cin >> n;     for (int i = 1; i < n; i++) {       cin >> a[i][0] >> a[i][1];       adj[a[i][0]].push_back(a[i][1]);       adj[a[i][1]].push_back(a[i][0]);     }     DFS(n - 1, 0, 1);     LCA();     cin >> q;     for (int i = 0; i < q; i++) {       int u, v;       cin >> u >> v;       if (h[u] > h[v]) swap(u, v);       int lca = find_lca(u, v);       mark[u]++;       mark[v]++;       mark[lca] -= 2;     }     dfs_sum(n - 1, 0);     for (int i = 1; i < n; i++) {       cout << max(m[a[i][0]][a[i][1]], m[a[i][1]][a[i][0]]) <<    ;     }   }   