#include <bits/stdc++.h>
const int N = 550000;
struct node {
  int x, y, next;
} data[N * 2];
int n, m, x, y, z, a[N], h[N], num1 = 0, s[N], b[N];
int dep[N], fa[N], son[N], size[N];
int fan[N], in[N], fnt[N], out[N];
bool flag[N];
void add1(int num, int a, int b) {
  data[num].x = a;
  data[num].y = b;
  data[num].next = h[a];
  h[a] = num;
}
void dfs1(int x) {
  size[x] = 1;
  int v = 0;
  for (int j = h[x]; j != -1; j = data[j].next) {
    int y = data[j].y;
    if (flag[y]) {
      flag[y] = false;
      dep[y] = dep[x] + 1;
      fa[y] = x;
      dfs1(y);
      size[x] += size[y];
      if (size[y] > size[v]) v = y;
    }
  }
  son[x] = v;
}
void dfs2(int x, int r) {
  in[x] = ++num1;
  fan[num1] = x;
  fnt[x] = r;
  if (son[x] && flag[son[x]]) {
    flag[son[x]] = false;
    dfs2(son[x], r);
  }
  for (int j = h[x]; j != -1; j = data[j].next) {
    int y = data[j].y;
    if (flag[y]) {
      flag[y] = false;
      dfs2(y, y);
    }
  }
  out[x] = num1;
}
int main() {
  scanf("%d", &n);
  memset(h, -1, sizeof(h));
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    add1(i * 2, x, y);
    add1(i * 2 + 1, y, x);
  }
  memset(flag, true, sizeof(flag));
  flag[1] = false;
  dep[1] = 1;
  fa[1] = 0;
  dfs1(1);
  memset(flag, true, sizeof(flag));
  flag[1] = false;
  dfs2(1, 1);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    while (1) {
      int x1 = fnt[x], dx = dep[x1];
      int y1 = fnt[y], dy = dep[y1];
      if (x1 == y1) {
        if (dep[x] > dep[y]) {
          int t = x;
          x = y;
          y = t;
        }
        s[in[x] + 1] += 1;
        s[in[y] + 1] -= 1;
        break;
      }
      if (dx > dy) {
        s[in[x1]] += 1;
        s[in[x] + 1] -= 1;
        x = fa[x1];
      } else {
        s[in[y1]] += 1;
        s[in[y] + 1] -= 1;
        y = fa[y1];
      }
    }
  }
  for (int i = 1; i <= n; i++) b[i] = b[i - 1] + s[i];
  for (int i = 2; i <= 2 * n - 1; i++) {
    if (fa[data[i].x] == data[i].y) printf("%d ", b[in[data[i].x]]);
  }
}
