#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 11;
const int inf = 0x3f3f3f3f;
struct node {
  int u, v;
} a[maxn];
int t, n, m;
int fa[maxn], head[maxn], fnext[maxn], ver[maxn], vis2[maxn], ans2[maxn],
    cnt = 0;
int dep[maxn], ff[maxn][20], minn[maxn][20];
void addedge(int x, int y) {
  fnext[++cnt] = head[x];
  head[x] = cnt;
  ver[cnt] = y;
}
void dfs(int rt, int fa) {
  vis2[rt] = 1;
  ff[rt][0] = fa;
  for (int i = 1; i <= 18; i++) {
    ff[rt][i] = ff[ff[rt][i - 1]][i - 1];
  }
  for (int i = head[rt]; i; i = fnext[i]) {
    int to = ver[i];
    if (!vis2[to]) {
      dep[to] = dep[rt] + 1;
      dfs(to, rt);
    }
  }
}
void change_min(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 18; i >= 0; i--) {
    if (dep[ff[x][i]] >= dep[y]) {
      minn[x][i] += 1;
      x = ff[x][i];
    }
  }
  if (x == y) return;
  for (int i = 18; i >= 0; i--) {
    if (ff[x][i] != ff[y][i]) {
      minn[x][i] += 1;
      minn[y][i] += 1;
      x = ff[x][i];
      y = ff[y][i];
    }
  }
  minn[x][0] += 1;
  minn[y][0] += 1;
}
void init() {
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    head[i] = 0;
  }
  memset(minn, 0, sizeof minn);
}
int main() {
  scanf("%d", &n);
  init();
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d", &a[i].u, &a[i].v);
    addedge(a[i].u, a[i].v);
    addedge(a[i].v, a[i].u);
  }
  dfs(1, 1);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    change_min(u, v);
  }
  for (int j = 18; j >= 1; j--) {
    for (int i = 1; i <= n; i++) {
      minn[i][j - 1] += minn[i][j];
      minn[ff[i][j - 1]][j - 1] += minn[i][j];
    }
  }
  for (int i = 1; i <= n - 1; i++) {
    if (ff[a[i].u][0] == a[i].v)
      ans2[i] = minn[a[i].u][0];
    else
      ans2[i] = minn[a[i].v][0];
  }
  for (int i = 1; i <= n - 1; i++) {
    if (i != n - 1)
      printf("%d ", ans2[i]);
    else
      printf("%d\n", ans2[i]);
  }
}
