#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
struct Edge {
  int a, b, pre;
} edge[N * 2];
int lazy[N << 2];
int pre[N], siz[N], son[N], top[N], dis[N], fa[N], wei[N];
int edge_num, wei_num, n;
void addedge(int a, int b) {
  edge[++edge_num] = (Edge){a, b, pre[a]};
  pre[a] = edge_num;
}
void dfs1(int u, int f, int d) {
  siz[u] = 1;
  son[u] = 0;
  dis[u] = d;
  fa[u] = f;
  for (int i = pre[u]; i; i = edge[i].pre) {
    int v = edge[i].b;
    if (v == f) continue;
    dfs1(v, u, d + 1);
    siz[u] += siz[v];
    if (siz[v] > siz[son[u]]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  wei[u] = ++wei_num;
  if (son[u]) dfs2(son[u], tp);
  for (int i = pre[u]; i; i = edge[i].pre) {
    int v = edge[i].b;
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v);
  }
}
void down(int node) {
  if (lazy[node] == 0) return;
  lazy[node << 1] += lazy[node];
  lazy[node << 1 | 1] += lazy[node];
  lazy[node] = 0;
}
void gai(int l, int r, int node, int ll, int rr) {
  if (l > rr || r < ll) return;
  if (l >= ll && r <= rr) {
    lazy[node]++;
    return;
  }
  down(node);
  int mid = (l + r) >> 1;
  gai(l, mid, node << 1, ll, rr);
  gai(mid + 1, r, node << 1 | 1, ll, rr);
}
int query(int l, int r, int node, int p) {
  if (l == r) return lazy[node];
  down(node);
  int mid = (l + r) >> 1;
  if (p <= mid)
    return query(l, mid, node << 1, p);
  else
    return query(mid + 1, r, node << 1 | 1, p);
}
void yongth(int a, int b) {
  int ta = top[a], tb = top[b];
  while (ta != tb) {
    if (dis[ta] > dis[tb]) {
      swap(ta, tb);
      swap(a, b);
    }
    gai(1, n, 1, wei[tb], wei[b]);
    b = fa[tb];
    tb = top[b];
  }
  if (a == b) return;
  if (dis[a] > dis[b]) swap(a, b);
  gai(1, n, 1, wei[son[a]], wei[b]);
}
int main() {
  scanf("%d", &n);
  int a, b;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    addedge(a, b);
    addedge(b, a);
  }
  dfs1(1, 1, 1);
  wei_num = 0;
  dfs2(1, 1);
  int k;
  scanf("%d", &k);
  while (k--) {
    scanf("%d%d", &a, &b);
    yongth(a, b);
  }
  for (int i = 2; i <= edge_num; i += 2) {
    a = edge[i].a, b = edge[i].b;
    if (dis[a] > dis[b]) swap(a, b);
    printf("%d ", query(1, n, 1, wei[b]));
  }
  printf("\n");
  return 0;
}
