#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, Lev[N], p[N][21], vis[N], w[N], ans[N];
vector<pair<int, int>> adj[N];
void bld(int u = 1, int par = 0, int d = 0) {
  p[u][0] = par;
  Lev[u] = d;
  int h = 1;
  while ((1 << h) <= d) {
    int x = p[u][h - 1];
    p[u][h] = p[x][h - 1];
    ++h;
  }
  for (auto v : adj[u])
    if (v.first != par) bld(v.first, u, d + 1);
}
int getParent(int u, int x) {
  for (int i = 0; i <= 20; i++)
    if ((x >> i) & 1) u = p[u][i];
  return u;
}
int LCA(int u, int v) {
  if (Lev[u] < Lev[v]) swap(u, v);
  u = getParent(u, Lev[u] - Lev[v]);
  if (u == v) return u;
  int LG = log2(Lev[u]) + 1e-9;
  for (int i = LG; ~i; i--) {
    if (p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  }
  return p[u][0];
}
void dfs(int u = 1) {
  vis[u] = 1;
  for (auto e : adj[u]) {
    if (!vis[e.first]) {
      dfs(e.first);
      w[u] += w[e.first];
      ans[e.second] = w[e.first];
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back({v, i});
    adj[v].push_back({u, i});
  }
  bld();
  int q;
  scanf("%d", &q);
  int i = q;
  while (q--) {
    int u, v;
    scanf("%d %d", &u, &v);
    w[LCA(u, v)] -= 2;
    w[v] += 1;
    w[u] += 1;
  }
  dfs();
  for (int j = 1; j < n; j++) cout << ans[j] << " ";
  return 0;
}
