#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
int F[MAX_N][30];
int n, query;
int H[MAX_N];
vector<pair<int, int> > V[MAX_N];
int cnt[MAX_N];
int res[MAX_N];
void DFS(int x, int father) {
  for (int i = 0; i < V[x].size(); i++) {
    int t = V[x][i].first;
    if (t == father) continue;
    H[t] = H[x] + 1;
    F[t][0] = x;
    DFS(t, x);
  }
}
void DFS2(int x, int father) {
  for (int i = 0; i < V[x].size(); i++) {
    int t = V[x][i].first;
    int pos = V[x][i].second;
    if (t == father) continue;
    DFS2(t, x);
    res[pos] = cnt[t];
    cnt[x] += cnt[t];
  }
}
void initLCA() {
  for (int k = 1; k <= 20; k++)
    for (int i = 1; i <= n; i++) F[i][k] = F[F[i][k - 1]][k - 1];
}
int lca(int u, int v) {
  if (H[u] < H[v]) swap(u, v);
  for (int i = 20; i >= 0; i--)
    if (H[u] - (1 << i) >= H[v]) u = F[u][i];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--)
    if (F[u][i] != F[v][i]) {
      u = F[u][i];
      v = F[v][i];
    }
  return F[u][0];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    V[u].push_back(make_pair(v, i));
    V[v].push_back(make_pair(u, i));
  }
  DFS(1, -1);
  initLCA();
  scanf("%d", &query);
  for (int i = 1; i <= query; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    int z = lca(u, v);
    cnt[u]++;
    cnt[v]++;
    cnt[z] -= 2;
  }
  DFS2(1, -1);
  for (int i = 1; i < n; i++) printf("%d ", res[i]);
  return 0;
}
