#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
namespace TREE {
int n;
int idx = 1, head[N], nxt[N << 1], to[N << 1];
int co[N << 1];
int size[N], fa[N][21], dep[N];
int dis[N], val[N], ans[N];
map<pair<int, int>, int> id;
void addedge(int u, int v, int w = 1) {
  to[idx] = v, nxt[idx] = head[u], head[u] = idx++;
}
void dfs(int u, int f) {
  size[u] = 1;
  fa[u][0] = f;
  for (int i = 1; i <= 20; i++) fa[u][i] = fa[fa[u][i - 1]][i - 1];
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i], w = co[i];
    if (v == f) continue;
    dis[v] = dis[u] + w;
    dep[v] = dep[u] + 1;
    dfs(v, u);
    size[u] += size[v];
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 20; i >= 0; i--)
    if (dep[fa[u][i]] >= dep[v]) u = fa[u][i];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  return fa[u][0];
}
int dist(int u, int v) { return dis[u] + dis[v] - 2 * dis[lca(u, v)]; }
void get_ans(int u, int f) {
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == f) continue;
    get_ans(v, u);
    val[u] += val[v];
  }
  if (u != 1) {
    ans[id[{u, f}]] = val[u];
  }
}
}  // namespace TREE
int main() {
  scanf("%d", &TREE::n);
  for (int i = 1; i < TREE::n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    TREE::id[{u, v}] = TREE::id[{v, u}] = i;
    TREE::addedge(u, v);
    TREE::addedge(v, u);
  }
  TREE::dfs(1, 1);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    TREE::val[u]++;
    TREE::val[v]++;
    TREE::val[TREE::lca(u, v)] -= 2;
  }
  TREE::get_ans(1, 1);
  for (int i = 1; i < TREE::n; i++) {
    printf("%d%c", TREE::ans[i], " \n"[i == TREE::n - 1]);
  }
  return 0;
}
