#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int to, ne, num;
} e[100010 * 2];
int n, m, d[100010][22], h[100010], a[100010], ans[100010], dep[100010];
void dfs(int u, int fa, int depth) {
  d[u][0] = fa;
  dep[u] = depth;
  for (int i = 1; (1 << i) < depth; i++) {
    d[u][i] = d[d[u][i - 1]][i - 1];
  }
  for (int i = h[u]; i != -1; i = e[i].ne) {
    if (e[i].to != fa) {
      dfs(e[i].to, u, depth + 1);
    }
  }
}
int LCA(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  int height = dep[a] - dep[b];
  for (int i = 0; (1 << i) <= height; i++) {
    if ((1 << i) & height) {
      a = d[a][i];
    }
  }
  for (int i = 20; i >= 0; i--) {
    if (d[a][i] != d[b][i]) {
      a = d[a][i];
      b = d[b][i];
    }
  }
  return (a == b ? a : d[a][0]);
}
int dfs_ans(int u, int fa) {
  int sum = a[u];
  for (int i = h[u]; i != -1; i = e[i].ne) {
    if (e[i].to != fa) {
      ans[e[i].num] = dfs_ans(e[i].to, u);
      sum += ans[e[i].num];
    }
  }
  return sum;
}
int main() {
  scanf("%d", &n);
  int cnt = 0, u, v;
  memset(h, -1, sizeof h);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    e[cnt].ne = h[u];
    h[u] = cnt;
    e[cnt].num = i;
    e[cnt++].to = v;
    e[cnt].ne = h[v];
    h[v] = cnt;
    e[cnt].num = i;
    e[cnt++].to = u;
  }
  scanf("%d", &m);
  memset(d, -1, sizeof d);
  memset(dep, 0, sizeof dep);
  dfs(1, -1, 1);
  memset(a, 0, sizeof 0);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    ++a[u];
    ++a[v];
    a[LCA(u, v)] -= 2;
  }
  memset(ans, 0, sizeof ans);
  dfs_ans(1, -1);
  for (int i = 1; i < n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
