#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
const int INF = 1000000000;
bool used[maxn];
int B[maxn], F[maxn], pos[maxn], tot, idx;
int LOG[maxn], dp[maxn][18];
int Min(int a, int b) { return a < b ? a : b; }
int one[maxn];
int zero[maxn];
int head[maxn], E;
struct Edge {
  int v, next, id;
} edge[maxn];
int ans[maxn];
void add_edge(int u, int v, int id) {
  edge[E].v = v;
  edge[E].id = id;
  edge[E].next = head[u];
  head[u] = E++;
}
void rmq_init(int n, int num[]) {
  int i, j;
  for (j = 1; j <= n; j++) dp[j][0] = num[j];
  int m = LOG[n];
  for (j = 1; j <= m; j++) {
    for (i = 1; i + (1 << j) <= n + 1; i++) {
      int x = i + (1 << j >> 1);
      dp[i][j] = Min(dp[x][j - 1], dp[i][j - 1]);
    }
  }
}
int rmq(int l, int r, int num[]) {
  int m = LOG[r - l + 1];
  return Min(dp[l][m], dp[r - (1 << m) + 1][m]);
}
void dfs(int s, int step) {
  int i, t;
  int tmp = ++idx;
  used[s] = 1;
  B[++tot] = tmp;
  F[tmp] = s;
  pos[s] = tot;
  for (i = head[s]; i != -1; i = edge[i].next) {
    t = edge[i].v;
    if (used[t]) continue;
    dfs(t, step + 1);
    B[++tot] = tmp;
  }
}
int LCA(int a, int b) {
  if (pos[a] > pos[b]) {
    int tmp = a;
    a = b;
    b = tmp;
  }
  int ans = rmq(pos[a], pos[b], B);
  return F[ans];
}
int dfs1(int u, int fa, int num_zero) {
  int i;
  num_zero += zero[u];
  int num_one = 0;
  for (i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].v;
    if (v == fa) continue;
    int t = dfs1(v, u, num_zero);
    ans[edge[i].id] = t;
    num_one += t;
  }
  return num_one + one[u] - zero[u];
}
int main() {
  int i, n, m;
  LOG[0] = -1;
  for (i = 1; i < maxn; i++) LOG[i] = LOG[i >> 1] + 1;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) head[i] = -1;
  E = 0;
  int x, y;
  for (i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    add_edge(x, y, i);
    add_edge(y, x, i);
  }
  dfs(1, 0);
  rmq_init(tot, B);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &x, &y);
    if (x == y) continue;
    int lca = LCA(x, y);
    if (x == lca) {
      zero[x]++;
      one[y]++;
    } else if (y == lca) {
      zero[y]++;
      one[x]++;
    } else {
      zero[lca] += 2;
      one[x]++;
      one[y]++;
    }
  }
  dfs1(1, 0, 0);
  for (i = 1; i < n; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
