#include <bits/stdc++.h>
using namespace std;
const int N = 100009;
struct Edge {
  int next;
  int ver;
  int id;
} e[N << 1];
int n;
int head[N];
int tot;
int d[N];
int f[N][30];
int t;
int cnt[N];
int ans[N];
queue<int> q;
void add(int x, int y, int i) {
  e[++tot].ver = y;
  e[tot].next = head[x];
  head[x] = tot;
  e[tot].id = i;
}
void bfs() {
  q.push(1), d[1] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = head[x]; i; i = e[i].next) {
      int y = e[i].ver;
      if (d[y]) continue;
      d[y] = d[x] + 1;
      f[y][0] = x;
      for (int j = 1; j <= t; j++) f[y][j] = f[f[y][j - 1]][j - 1];
      q.push(y);
    }
  }
}
int lca(int x, int y) {
  if (d[x] > d[y]) swap(x, y);
  for (int i = t; i >= 0; i--)
    if (d[f[y][i]] >= d[x]) y = f[y][i];
  if (x == y) return x;
  for (int i = t; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
void solve(int u, int fa) {
  for (int i = head[u]; i; i = e[i].next) {
    int y = e[i].ver;
    if (y == fa) continue;
    solve(y, u);
    cnt[u] += cnt[y];
    ans[e[i].id] = cnt[y];
  }
}
int main() {
  scanf("%d", &n);
  t = (int)(log(n) / log(2)) + 1;
  for (int i = 1; i <= n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    add(a, b, i);
    add(b, a, i);
  }
  bfs();
  int k;
  scanf("%d", &k);
  for (int i = 1; i <= k; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    cnt[a]++;
    cnt[b]++;
    cnt[lca(a, b)] -= 2;
  }
  solve(1, 0);
  for (int i = 1; i <= n - 1; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
