#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
template <class t>
inline void writeln(t x) {
  write(x);
  putchar('\n');
  return;
}
template <class t>
inline void write_blank(t x) {
  write(x);
  putchar(' ');
  return;
}
struct edge {
  int to, nxt, w;
} e[200010];
int n, k, u, cnt1, v, deep[200010], sum[200010], ans[200010], head[200010],
    f[200010][30];
void add(int u, int v, int w) {
  e[++cnt1].nxt = head[u];
  e[cnt1].to = v;
  e[cnt1].w = w;
  head[u] = cnt1;
}
void dfs1(int u, int fa) {
  f[u][0] = fa;
  for (int i = head[u]; i != -1; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) {
      continue;
    }
    deep[v] = deep[u] + 1;
    dfs1(v, u);
  }
}
int lca(int x, int y) {
  if (deep[x] < deep[y]) {
    swap(x, y);
  }
  int del = deep[x] - deep[y];
  for (int i = 0; i <= 20; i++) {
    if (del & (1 << i)) {
      x = f[x][i];
    }
  }
  if (x == y) {
    return x;
  }
  for (int i = 20; 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 != -1; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) {
      continue;
    }
    solve(v, u);
    sum[u] += sum[v];
    ans[e[i].w] = sum[v];
  }
}
int main() {
  memset(head, -1, sizeof(head));
  read(n);
  for (int i = 1; i < n; i++) {
    read(u);
    read(v);
    add(u, v, i);
    add(v, u, i);
  }
  dfs1(1, 0);
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j <= n; j++) {
      f[j][i] = f[f[j][i - 1]][i - 1];
    }
  }
  read(k);
  for (int i = 1; i <= k; i++) {
    int x, y;
    read(x);
    read(y);
    sum[x]++;
    sum[y]++;
    sum[lca(x, y)] -= 2;
  }
  solve(1, 0);
  for (int i = 1; i < n; i++) {
    write_blank(ans[i]);
  }
  return 0;
}
