#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 1e5 + 10, M = 2e5 + 10;
int n, m, cnt, hd[N], dep[N], f[N][20], v[N];
struct edge {
  int nxt, to;
} e[M];
inline void ins(int from, int to) {
  e[++cnt] = (edge){hd[from], to};
  hd[from] = cnt;
}
void dfs(int x, int fa) {
  for (int i = hd[x]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (to == fa) continue;
    dep[to] = dep[x] + 1;
    f[to][0] = x;
    dfs(to, x);
  }
}
inline int lca(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  int d = dep[a] - dep[b];
  for (int i = 0; i <= 18; ++i)
    if (d & (1 << i)) a = f[a][i];
  if (a == b) return a;
  for (int i = 18; i >= 0; --i)
    if (f[a][i] != f[b][i]) {
      a = f[a][i];
      b = f[b][i];
    }
  return f[a][0];
}
void getsum(int x, int fa) {
  for (int i = hd[x]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (to == fa) continue;
    getsum(to, x);
    v[x] += v[to];
  }
}
int main() {
  n = read();
  for (int i = 1; i < n; ++i) {
    int x = read(), y = read();
    ins(x, y);
    ins(y, x);
  }
  dfs(1, 0);
  for (int j = 1; j <= 18; ++j)
    for (int i = 1; i <= n; ++i) f[i][j] = f[f[i][j - 1]][j - 1];
  m = read();
  while (m--) {
    int x = read(), y = read();
    ++v[x];
    ++v[y];
    v[lca(x, y)] -= 2;
  }
  getsum(1, 0);
  for (int i = 1; i < cnt; i += 2) {
    int x = e[i + 1].to, y = e[i].to;
    if (dep[x] < dep[y]) swap(x, y);
    printf("%d", v[x]);
    if (i + 1 == cnt)
      puts("");
    else
      putchar(' ');
  }
  return 0;
}
