#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, ans[N], tu[N], de[N], f[N][20];
int tot = 1, fi[N], ne[N << 1], a[N << 1];
inline void Add(int x, int y) {
  a[++tot] = y;
  ne[tot] = fi[x];
  fi[x] = tot;
}
inline void Fpre(int x, int fa) {
  de[x] = de[fa] + 1;
  f[x][0] = fa;
  for (int i = 1; i <= 19; ++i) f[x][i] = f[f[x][i - 1]][i - 1];
  for (int i = fi[x]; i; i = ne[i])
    if (a[i] != fa) Fpre(a[i], x);
}
inline int GetLca(int x, int y) {
  if (de[x] < de[y]) swap(x, y);
  for (int i = 19; ~i; --i)
    if (de[f[x][i]] >= de[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = 19; ~i; --i)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
inline void GetAns(int x, int fa, int ansid) {
  for (int i = fi[x]; i; i = ne[i])
    if (a[i] != fa) GetAns(a[i], x, i >> 1), tu[x] += tu[a[i]];
  ans[ansid] = tu[x];
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i < n; ++i) scanf("%d%d", &x, &y), Add(x, y), Add(y, x);
  Fpre(1, 0);
  scanf("%d", &m);
  for (int i = 1, x, y, lca; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    ++tu[x];
    ++tu[y];
    lca = GetLca(x, y);
    tu[lca] -= 2;
  }
  GetAns(1, 0, 0);
  for (int i = 1; i < n; ++i) printf("%d ", ans[i]);
  return 0;
}
