#include <bits/stdc++.h>
using namespace std;
int L[100005], Dp[100005], Ans[100005];
int P[100005][20];
int T[100005], n;
vector<int> Graph[100005];
map<pair<int, int>, int> Edge;
void Dfs(int from, int u, int dep) {
  T[u] = from;
  L[u] = dep;
  for (int i = 0; i < Graph[u].size(); i++) {
    int v = Graph[u][i];
    if (v == from) continue;
    Dfs(u, v, dep + 1);
  }
}
void Lca_init() {
  int i, j;
  for (i = 0; i < n; i++)
    for (j = 0; 1 << j < n; j++) P[i][j] = -1;
  for (i = 0; i < n; i++) P[i][0] = T[i];
  for (j = 1; 1 << j < n; j++)
    for (i = 0; i < n; i++)
      if (P[i][j - 1] != -1) P[i][j] = P[P[i][j - 1]][j - 1];
}
int Lca_query(int p, int q) {
  int log, i;
  if (L[p] < L[q]) swap(p, q);
  for (log = 1; 1 << log <= L[p]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--)
    if (L[p] - (1 << i) >= L[q]) p = P[p][i];
  if (p == q) return p;
  for (i = log; i >= 0; i--)
    if (P[p][i] != -1 && P[p][i] != P[q][i]) p = P[p][i], q = P[q][i];
  return T[p];
}
void Add(int p, int q) {
  Dp[p]++;
  Dp[q]--;
}
void Go(int u, int from) {
  for (int i = 0; i < Graph[u].size(); i++) {
    int v = Graph[u][i];
    if (v == from) continue;
    Go(v, u);
    Dp[u] += Dp[v];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    Graph[u].push_back(v);
    Graph[v].push_back(u);
    Edge[pair<int, int>(u, v)] = i;
    Edge[pair<int, int>(v, u)] = i;
  }
  Dfs(-1, 0, 0);
  Lca_init();
  int qur;
  scanf("%d", &qur);
  while (qur--) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    int lca = Lca_query(u, v);
    Add(u, lca);
    Add(v, lca);
  }
  Go(0, -1);
  for (int i = 1; i < n; i++) Ans[Edge[pair<int, int>(i, P[i][0])]] = Dp[i];
  for (int i = 0; i < n - 1; i++) printf("%d ", Ans[i]);
  return 0;
}
