#include <bits/stdc++.h>
using namespace std;
vector<int> G[100100], Path[100100];
int sparse[100100][23], lvl[100100], Edge[100100], Start[100100], End[100100];
void dfs(int u, int par = -1, int level = 0) {
  if (par != -1) sparse[u][0] = par;
  lvl[u] = level;
  for (auto v : G[u])
    if (v != par) dfs(v, u, level + 1);
}
int LCA(int u, int v) {
  if (lvl[u] < lvl[v]) swap(u, v);
  for (int p = 20; p >= 0 and lvl[u] != lvl[v]; --p)
    if (lvl[u] - (1 << p) >= lvl[v]) u = sparse[u][p];
  if (u == v) return u;
  for (int p = 20; p >= 0; --p)
    if (sparse[u][p] != -1 and sparse[u][p] != sparse[v][p])
      u = sparse[u][p], v = sparse[v][p];
  return sparse[u][0];
}
int dfs2(int u, int par = -1, int pathNo = 0) {
  int ret = 0;
  for (int i = 0; i < G[u].size(); ++i)
    if (G[u][i] != par) ret += dfs2(G[u][i], u, Path[u][i]);
  ret += Start[u] - 2 * End[u];
  Edge[pathNo] = ret;
  return ret;
}
int main() {
  int n, u, v, q, w;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
    Path[u].push_back(i);
    Path[v].push_back(i);
  }
  memset(sparse, -1, sizeof sparse);
  dfs(1);
  for (int p = 1; (1 << p) <= n; ++p)
    for (int u = 1; u <= n; ++u) sparse[u][p] = sparse[sparse[u][p - 1]][p - 1];
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &u, &v);
    w = LCA(u, v);
    ++Start[u], ++Start[v], ++End[max(w, 0)];
  }
  dfs2(1);
  for (int i = 1; i < n; ++i) printf("%d ", Edge[i]);
}
