#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const int POW = 17;
int p[maxn][POW];
vector<int> edge[maxn], ee[maxn];
int cnt[maxn];
int dep[maxn];
void dfs(int u, int f) {
  dep[u] = dep[f] + 1;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    if (v == f) continue;
    p[v][0] = u;
    for (int j = 1; j < POW; j++) p[v][j] = p[p[v][j - 1]][j - 1];
    dfs(v, u);
  }
}
int LCA(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  if (dep[a] < dep[b]) {
    int del = dep[b] - dep[a];
    for (int i = 0; i < POW; i++)
      if (del & (1 << i)) b = p[b][i];
  }
  if (a != b) {
    for (int i = POW - 1; i >= 0; i--)
      if (p[a][i] != p[b][i]) a = p[a][i], b = p[b][i];
    a = p[a][0], b = p[b][0];
  }
  return a;
}
int ans[maxn];
int la[maxn];
bool vis[maxn];
int solve(int u, int edge_num) {
  vis[u] = true;
  int sum = 0;
  for (int i = 0; i < edge[u].size(); i++) {
    int v = edge[u][i];
    if (vis[v]) continue;
    sum += solve(v, ee[u][i]);
  }
  sum += cnt[u];
  return ans[edge_num] = sum;
}
int main() {
  int n, u, v;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
    ee[u].push_back(i);
    ee[v].push_back(i);
  }
  int m;
  dfs(1, 0);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    cnt[u]++;
    cnt[v]++;
    cnt[LCA(u, v)] -= 2;
  }
  solve(1, 0);
  for (int i = 1; i < n; i++) printf("%d ", ans[i]);
  return 0;
}
