#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<pair<int, int> > adj[N];
int ans[N];
int off[N];
int lvl[N], anc[N][25];
int n, a, b, k;
void dfs(int u = 0, int par = 0, int l = 0) {
  lvl[u] = l;
  anc[u][0] = par;
  for (auto nxt : adj[u])
    if (nxt.first != par) dfs(nxt.first, u, l + 1);
}
void buildLCA() {
  int lg = ceil(log2(n));
  for (int j = 1; j < lg; j++)
    for (int i = 0; i < n; i++) anc[i][j] = anc[anc[i][j - 1]][j - 1];
}
int LCA(int i, int j) {
  int lg = ceil(log2(n));
  int st = lg;
  if (lvl[i] > lvl[j]) swap(i, j);
  int cur = lvl[j];
  for (; st >= 0; st--)
    if (cur - (1 << st) >= lvl[i]) cur -= (1 << st), j = anc[j][st];
  if (i == j) return 2 * i - j;
  cur = lvl[i];
  for (st = lg; st >= 0; st--)
    if (anc[i][st] != anc[j][st])
      cur -= (1 << st), i = anc[i][st], j = anc[j][st];
  return anc[i][0];
}
int solve(int u = 0, int par = 0) {
  int cnt = off[u];
  for (auto nxt : adj[u]) {
    if (par == nxt.first) continue;
    int x = solve(nxt.first, u);
    ans[nxt.second] = x;
    cnt += x;
  }
  return cnt;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &a, &b);
    a--, b--;
    adj[a].push_back({b, i});
    adj[b].push_back({a, i});
  }
  dfs();
  buildLCA();
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    scanf("%d%d", &a, &b);
    a--, b--;
    off[a]++, off[b]++;
    off[LCA(a, b)] -= 2;
  }
  solve();
  for (int i = 0; i < n - 1; i++) printf("%d%c", ans[i], " \n"[i == n - 2]);
  return 0;
}
