#include <bits/stdc++.h>
using namespace std;
int T[100100], P[100100][30], L[100100];
vector<vector<pair<int, int> > > vec(100100);
int cnt[100100], LCAcnt[100100];
int ans[100100];
void dfs_root(int v, int p = 0, int d = 0) {
  T[v] = p;
  L[v] = d;
  for (int i = 0; i < vec[v].size(); i++)
    if (vec[v][i].first != p) dfs_root(vec[v][i].first, v, d + 1);
}
void dp_process() {
  int i, j;
  for (i = 0; i < 100100; i++)
    for (j = 0; 1 << j < 100100; j++) P[i][j] = -1;
  for (i = 0; i < 100100; i++) P[i][0] = T[i];
  for (j = 1; 1 << j < 100100; j++)
    for (i = 0; i < 100100; i++)
      if (P[i][j - 1] != -1) {
        int temp = P[i][j - 1];
        P[i][j] = P[temp][j - 1];
      }
}
int lca_query(int p, int q) {
  int tmp, log, i;
  if (L[p] < L[q]) tmp = p, p = q, q = tmp;
  for (log = 1; 1 << log <= L[p]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--)
    if (L[p] - (1 << i) >= L[q]) p = P[p][i];
  if (p == q) return p;
  for (i = log; i >= 0; i--)
    if (P[p][i] != -1 && P[p][i] != P[q][i]) p = P[p][i], q = P[q][i];
  return T[p];
}
void dfs(int v = 1, int p = -1, int e = -1) {
  for (int i = 0; i < vec[v].size(); i++) {
    if (vec[v][i].first != p) dfs(vec[v][i].first, v, vec[v][i].second);
  }
  long long res = cnt[v];
  for (int i = 0; i < vec[v].size(); i++)
    if (vec[v][i].first != p) res += ans[vec[v][i].second];
  res -= 2 * LCAcnt[v];
  if (e > -1) ans[e] = res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int i, n;
  int u, v;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> u >> v;
    vec[u].push_back({v, i});
    vec[v].push_back({u, i});
  }
  dfs_root(1);
  dp_process();
  int k;
  cin >> k;
  while (k--) {
    cin >> u >> v;
    cnt[u]++;
    cnt[v]++;
    int x = lca_query(u, v);
    LCAcnt[x]++;
  }
  dfs();
  for (i = 0; i < n - 1; i++) cout << ans[i] << " ";
  return 0;
}
