#include <bits/stdc++.h>
using namespace std;
int n, q, a, b;
int P[100005][20], cnt[100005], res[100005];
int L[100005], Id[100005];
vector<pair<int, int> > graph[100005];
void Bulid(int v) {
  for (int i = 0; i < graph[v].size(); i++) {
    pair<int, int> u = graph[v][i];
    if (P[v][0] != u.first) {
      P[u.first][0] = v;
      L[u.first] = L[v] + 1;
      Id[u.first] = u.second;
      Bulid(u.first);
    }
  }
}
int getlca(int u, int v) {
  if (L[u] < L[v]) swap(u, v);
  for (int k = 19; k >= 0; k--)
    if (L[u] - (1 << k) >= L[v]) u = P[u][k];
  if (u == v) return u;
  for (int k = 19; k >= 0; k--) {
    if (P[u][k] != P[v][k]) {
      u = P[u][k];
      v = P[v][k];
    }
  }
  return P[u][0];
}
void getans(int v) {
  for (int i = 0; i < graph[v].size(); i++) {
    pair<int, int> u = graph[v][i];
    if (P[v][0] != u.first) {
      getans(u.first);
      res[Id[u.first]] = cnt[u.first];
      cnt[v] += cnt[u.first];
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    graph[a].push_back(make_pair(b, i));
    graph[b].push_back(make_pair(a, i));
  }
  memset(P, -1, sizeof(P));
  Bulid(1);
  for (int k = 1; k < 20; k++) {
    for (int v = 1; v <= n; v++) {
      if (P[v][k - 1] < 0)
        P[v][k] = -1;
      else
        P[v][k] = P[P[v][k - 1]][k - 1];
    }
  }
  cin >> q;
  while (q--) {
    cin >> a >> b;
    int lca = getlca(a, b);
    cnt[a]++;
    cnt[b]++;
    cnt[lca]--;
    cnt[lca]--;
  }
  getans(1);
  for (int i = 1; i < n; i++) cout << res[i] << " ";
  return 0;
}
