#include <bits/stdc++.h>
using namespace std;
int n, v[100005 + 100005], o[100005 + 100005], f[100005], t, g[100005 + 100005];
int e[100005 + 100005], l[100005], h[100005], s[18][100005 + 100005], c[100005],
    a[100005];
int odp(int a, int b) { return l[a] < l[b] ? a : b; }
void dfs(int V, int P) {
  h[V] = ++t;
  l[V] = l[P] + 1;
  e[t] = V;
  for (int i = (f[V]); i; i = o[i])
    if (v[i] != P) {
      dfs(v[i], V);
      e[++t] = V;
    }
}
int cnt(int V, int P) {
  for (int i = (f[V]); i; i = o[i])
    if (v[i] != P) c[V] += a[i + 1 >> 1] = cnt(v[i], V);
  return c[V];
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i < (n); i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v[++t] = b;
    o[t] = f[a];
    f[a] = t;
    v[++t] = a;
    o[t] = f[b];
    f[b] = t;
  }
  t = 0;
  dfs(1, 0);
  g[1] = 0;
  for (int i = (2); i <= (t); i++) g[i] = g[i >> 1] + 1;
  for (int i = (1); i <= (t); i++) s[0][i] = e[i];
  for (int j = (1); j <= (g[t]); j++)
    for (int i = (1); i <= (t + 1 - (1 << j)); i++)
      s[j][i] = odp(s[j - 1][i], s[j - 1][i + (1 << j - 1)]);
  scanf("%d", &t);
  while (t--) {
    int a, b, j;
    scanf("%d %d", &a, &b);
    c[a]++;
    c[b]++;
    a = h[a], b = h[b];
    if (a > b) swap(a, b);
    j = g[b - a + 1];
    c[odp(s[j][a], s[j][b - (1 << j) + 1])] -= 2;
  }
  cnt(1, 0);
  for (int i = (1); i < (n); i++) printf("%d%c", a[i], i == n - 1 ? '\n' : ' ');
}
