#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct node {
  int to, nxt;
} g[N << 1];
int n, head[N], d[N], k[N], f[30][N], cnt[N], u[N], v[N], q, gsz;
void add(int u, int v) {
  g[++gsz] = (node){v, head[u]};
  head[u] = gsz;
}
void dfs(int x, int fa) {
  d[x] = d[fa] + 1, k[x] = log2(d[x]);
  f[0][x] = fa;
  for (int i = 1; i <= k[x]; i++) f[i][x] = f[i - 1][f[i - 1][x]];
  for (int p = head[x]; p; p = g[p].nxt)
    if (g[p].to != fa) dfs(g[p].to, x);
}
int lca(int u, int v) {
  if (d[u] > d[v]) swap(u, v);
  for (int i = k[v]; i >= 0; i--)
    if (d[v] - (1 << i) >= d[u]) v = f[i][v];
  if (u == v) return u;
  for (int i = k[u]; i >= 0; i--)
    if (f[i][u] != f[i][v]) u = f[i][u], v = f[i][v];
  return f[0][u];
}
int sum(int x, int fa) {
  for (int p = head[x]; p; p = g[p].nxt)
    if (g[p].to != fa) cnt[x] += sum(g[p].to, x);
  return cnt[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d", u + i, v + i);
    add(u[i], v[i]), add(v[i], u[i]);
  }
  dfs(1, 0);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int a, b, x;
    scanf("%d%d", &a, &b);
    x = lca(a, b);
    cnt[a]++, cnt[b]++, cnt[x] -= 2;
  }
  sum(1, 0);
  for (int i = 1; i <= n - 1; i++) {
    if (d[u[i]] > d[v[i]])
      printf("%d ", cnt[u[i]]);
    else
      printf("%d ", cnt[v[i]]);
  }
  return 0;
}
