#include <bits/stdc++.h>
using namespace std;
int N, M;
int par[(int)1e5 + 3][21], depth[(int)1e5 + 3], dp[(int)1e5 + 3],
    ans[(int)1e5 + 3];
vector<int> v[(int)1e5 + 3];
map<pair<int, int>, int> mp;
void dfs(int n, int p) {
  depth[n] = depth[p] + 1;
  par[n][0] = p;
  for (int i = 0; i < v[n].size(); i++) {
    if (v[n][i] != p) dfs(v[n][i], n);
  }
}
void precompute() {
  for (int i = 1; i <= 20; i++) {
    for (int node = 1; node <= N; node++) {
      if (par[node][i - 1] != -1) par[node][i] = par[par[node][i - 1]][i - 1];
    }
  }
}
int lca(int u, int v) {
  if (depth[v] < depth[u]) swap(u, v);
  int diff = depth[v] - depth[u];
  for (int i = 0; i <= 20; i++)
    if ((diff >> i) & 1) v = par[v][i];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--)
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  return par[u][0];
}
void Count(int n, int p) {
  for (int i = 0; i < v[n].size(); i++) {
    int to = v[n][i];
    if (to == p) continue;
    Count(to, n);
    dp[n] += dp[to];
    int idx = mp[make_pair(to, n)];
    ans[idx] = dp[to];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    mp[make_pair(x, y)] = mp[make_pair(y, x)] = i;
  }
  cin >> M;
  dfs(1, -1);
  precompute();
  while (M--) {
    int x, y;
    cin >> x >> y;
    int z = lca(x, y);
    dp[z] -= 2;
    dp[x]++;
    dp[y]++;
  }
  Count(1, -1);
  for (int i = 0; i < N - 1; i++) cout << ans[i] << ' ';
  return 0;
}
