#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
const int M = N << 1;
const int Lg = 20;
int n, m, head[N], Next[M], v[M], cnt;
int dep[N], f[N][Lg];
long long tag[N], ans[N];
void read(int &x) {
  char ch = getchar();
  x = 0;
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 3) + (x << 1) + ch - '0';
}
void add(int x, int y) {
  Next[++cnt] = head[x];
  head[x] = cnt;
  v[cnt] = y;
}
void dfs(int x, int fa) {
  f[x][0] = fa;
  dep[x] = dep[fa] + 1;
  for (int i = 1; i < Lg; i++) f[x][i] = f[f[x][i - 1]][i - 1];
  for (int i = head[x]; i != -1; i = Next[i])
    if (v[i] != fa) dfs(v[i], x);
}
void ddfs(int x, int fa) {
  for (int i = head[x]; i != -1; i = Next[i])
    if (v[i] != fa) {
      ddfs(v[i], x);
      ans[i / 2] += tag[v[i]];
      tag[x] += tag[v[i]];
    }
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) x ^= y ^= x ^= y;
  for (int i = Lg - 1; i >= 0; i--)
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = Lg - 1; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
int main() {
  read(n);
  memset(head, -1, sizeof head);
  cnt = 1;
  for (int i = 1; i < n; i++) {
    int x, y;
    read(x);
    read(y);
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  read(m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    read(x);
    read(y);
    tag[x]++;
    tag[y]++;
    tag[lca(x, y)] -= 2;
  }
  ddfs(1, 0);
  for (int i = 1; i < n; i++) printf("%I64d ", ans[i]);
  return 0;
}
