#include <bits/stdc++.h>
using namespace std;
int n;
int freq[100005];
int L[100005];
int P[100005][20];
int parent_edge[100005];
vector<pair<int, int> > adj[100005];
int cnt[100005];
void dfs(int node, int depth, int parent) {
  L[node] = depth;
  P[node][0] = parent;
  for (int i = 0; i < (int)adj[node].size(); i++)
    if (adj[node][i].first != parent) {
      parent_edge[adj[node][i].first] = adj[node][i].second;
      dfs(adj[node][i].first, depth + 1, node);
    }
}
void init() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; 1 << j <= n; j++) P[i][j] = -1;
  for (int j = 1; 1 << j <= n; j++)
    for (int i = 1; i <= n; i++)
      if (P[i][j - 1] != -1) P[i][j] = P[P[i][j - 1]][j - 1];
}
int LCA(int u, int v) {
  if (L[u] < L[v]) swap(u, v);
  int log = log2(L[u]);
  for (int i = log; i >= 0; i--)
    if (L[u] - (1 << i) >= L[v]) u = P[u][i];
  if (u == v) return u;
  for (int i = log; i >= 0; i--)
    if (P[u][i] != -1 && P[u][i] != P[v][i]) u = P[u][i], v = P[v][i];
  return P[u][0];
}
int dfs(int node, int parent) {
  int tot = cnt[node];
  for (int i = 0; i < (int)adj[node].size(); i++)
    if (adj[node][i].first != parent) {
      int temp = dfs(adj[node][i].first, node);
      tot += temp;
      freq[adj[node][i].second] += temp;
    }
  return tot;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(make_pair(b, i));
    adj[b].push_back(make_pair(a, i));
  }
  dfs(1, 0, -1);
  init();
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    int lca = LCA(a, b);
    cnt[a]++;
    cnt[b]++;
    cnt[lca] -= 2;
  }
  dfs(1, -1);
  for (int i = 0; i < n - 1; i++) printf("%d ", freq[i]);
  printf("\n");
  return 0;
}
