#include <bits/stdc++.h>
using namespace std;
int N, K, sum[100100], pred[100100][17], viz[100100], Ind[100100], lev[100100];
vector<pair<int, int> > G[100100];
void dfs(int x) {
  viz[x] = 1;
  for (int i = 0; i < G[x].size(); i++)
    if (!viz[G[x][i].first]) {
      int y = G[x][i].first;
      pred[y][0] = x;
      Ind[G[x][i].second] = y;
      lev[y] = lev[x] + 1;
      dfs(y);
    }
}
void dfs1(int x) {
  viz[x] = 1;
  for (int i = 0; i < G[x].size(); i++)
    if (!viz[G[x][i].first]) {
      int y = G[x][i].first;
      dfs1(y);
      sum[x] += sum[y];
    }
}
int calc(int x, int lev) {
  int ret = x;
  for (int i = 16; i >= 0; i--)
    if (lev >= (1 << i)) ret = pred[ret][i], lev -= (1 << i);
  return (ret == 0 ? 1 : ret);
}
int lca(int x, int y) {
  int st, dr, mid, ret, aux;
  st = 0, dr = N - 1;
  while (st <= dr) {
    mid = (st + dr) / 2;
    if ((aux = calc(x, mid + (lev[x] > lev[y] ? lev[x] - lev[y] : 0))) ==
        calc(y, mid + (lev[y] > lev[x] ? lev[y] - lev[x] : 0)))
      ret = aux, dr = mid - 1;
    else
      st = mid + 1;
  }
  return ret;
}
int main(void) {
  int i, j, k, a, b;
  scanf("%d", &N);
  for (i = 1; i < N; i++) {
    scanf("%d %d", &a, &b);
    G[a].push_back(make_pair(b, i));
    G[b].push_back(make_pair(a, i));
  }
  dfs(1);
  for (i = 1; i < 17; i++)
    for (j = 1; j <= N; j++) pred[j][i] = pred[pred[j][i - 1]][i - 1];
  scanf("%d", &K);
  for (i = 1; i <= K; i++) {
    scanf("%d %d", &a, &b);
    int q = lca(a, b);
    sum[q] -= 2;
    sum[a] += 1;
    sum[b] += 1;
  }
  for (i = 1; i <= N; i++) viz[i] = 0;
  dfs1(1);
  for (i = 1; i < N; i++) printf("%d ", sum[Ind[i]]);
  return 0;
}
