#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
const int lg = 18;
int anc[1 + maxn][1 + lg];
vector<int> edge[1 + maxn];
vector<int> visit(1 + maxn, 0);
vector<int> ct(1 + maxn, 0);
vector<int> parent_edge(1 + maxn, 0);
vector<int> res(1 + maxn, 0);
vector<int> depth(1 + maxn, 0);
void dfs(int u) {
  for (int v : edge[u]) {
    if (visit[v]) continue;
    visit[v] = 1;
    anc[v][0] = u;
    depth[v] = depth[u] + 1;
    dfs(v);
  }
}
int dfs2(int u) {
  int ans = ct[u];
  for (int v : edge[u]) {
    if (anc[u][0] == v) continue;
    ans += dfs2(v);
  }
  res[parent_edge[u]] += ans;
  return ans;
}
int lca(int u, int v) {
  for (int e = lg; e >= 0; e--) {
    if (depth[u] - (1 << e) >= depth[v]) u = anc[u][e];
  }
  for (int e = lg; e >= 0; e--) {
    if (depth[v] - (1 << e) >= depth[u]) v = anc[v][e];
  }
  if (u == v) return u;
  for (int e = lg; e >= 0; e--) {
    if (anc[u][e] != anc[v][e]) {
      u = anc[u][e];
      v = anc[v][e];
    }
  }
  u = anc[u][0];
  return u;
}
int main() {
  int n;
  cin >> n;
  int u[n], v[n];
  for (int e = 1; e <= n - 1; e++) {
    cin >> u[e] >> v[e];
    edge[u[e]].push_back(v[e]);
    edge[v[e]].push_back(u[e]);
  }
  visit[1] = 1;
  anc[1][0] = 0;
  anc[0][0] = 0;
  depth[1] = 0;
  dfs(1);
  for (int e = 1; e <= lg; e++)
    for (int i = 1; i <= n; i++) anc[i][e] = anc[anc[i][e - 1]][e - 1];
  int k;
  cin >> k;
  for (int i = 1; i <= k; i++) {
    int a, b;
    cin >> a >> b;
    if (depth[a] > depth[b]) swap(a, b);
    int L = lca(a, b);
    if (L == a) {
      ct[a]--;
      ct[b]++;
    } else {
      ct[a]++;
      ct[b]++;
      ct[lca(a, b)] -= 2;
    }
  }
  for (int e = 1; e <= n - 1; e++) {
    if (depth[u[e]] > depth[v[e]])
      parent_edge[u[e]] = e;
    else
      parent_edge[v[e]] = e;
  }
  dfs2(1);
  for (int e = 1; e <= n - 1; e++) cout << res[e] << ' ';
  cout << '\n';
}
