#include <bits/stdc++.h>
using namespace std;
using namespace std;
struct node {
  int to, id;
};
vector<node> edge[2 * 200010];
int LOG[2 * 200010];
int cnt;
int tot;
int n;
int used[200010];
int B[2 * 200010];
int F[200010];
int pos[200010];
int dp[20][200010];
int f1[200010];
int vis[200010];
int ans[200010];
int flag[200010];
void add(int u, int v, int i) {
  edge[u].push_back((node){v, i});
  edge[v].push_back((node){u, i});
}
void init() {
  LOG[0] = -1;
  for (int i = 1; i <= 2 * 200010; i++) {
    LOG[i] = LOG[i >> 1] + 1;
  }
  cnt = 0;
  tot = 0;
  memset(used, 0, sizeof(used));
  memset(flag, 0, sizeof(flag));
  memset(B, 0, sizeof(B));
  memset(pos, 0, sizeof(pos));
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= 200010; i++) {
    edge[i].clear();
  }
}
void dfs(int u) {
  used[u] = 1;
  int tmp = ++tot;
  B[++cnt] = tmp;
  F[tmp] = u;
  pos[u] = cnt;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i].to;
    if (used[v]) continue;
    dfs(v);
    B[++cnt] = tmp;
  }
}
void rmq_init(int x, int num[]) {
  for (int i = 1; i <= x; i++) {
    dp[0][i] = num[i];
  }
  for (int i = 1; i <= LOG[x]; i++) {
    int limit = x + 1 - (1 << i);
    for (int j = 1; j <= limit; j++) {
      int q = j + (1 << i >> 1);
      dp[i][j] = min(dp[i - 1][j], dp[i - 1][q]);
    }
  }
}
int rmq(int a, int b, int num[]) {
  int j = LOG[b - a + 1];
  return min(dp[j][a], dp[j][b - (1 << j) + 1]);
}
int lca(int a, int b) {
  if (pos[a] > pos[b]) {
    int temp = a;
    a = b;
    b = temp;
  }
  int ans = rmq(pos[a], pos[b], B);
  return F[ans];
}
void anscount(int u) {
  vis[u] = 1;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i].to;
    if (vis[v]) continue;
    anscount(v);
    f1[u] += f1[v];
    ans[edge[u][i].id] += f1[v];
  }
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v, i);
  }
  dfs(1);
  rmq_init(cnt, B);
  int q;
  scanf("%d", &q);
  while (q--) {
    int u, v;
    scanf("%d%d", &u, &v);
    int z = lca(u, v);
    f1[u]++;
    f1[v]++;
    f1[z] -= 2;
  }
  anscount(1);
  for (int i = 1; i < n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
