#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, lg = 20;
int n, road[N], fools[N], lcpa[N][lg], level[N], ans[N];
vector<pair<int, int>> adj[N];
void dfs(int u, int v, int l, int r) {
  level[u] = l;
  road[u] = r;
  lcpa[u][0] = v;
  for (auto it : adj[u]) {
    if (it.first == v) continue;
    dfs(it.first, u, l + 1, it.second);
  }
}
int lcp(int u, int v) {
  if (level[u] < level[v]) swap(u, v);
  for (int i = lg - 1; i > -1; i--) {
    if (level[u] - (1 << i) >= level[v]) {
      u = lcpa[u][i];
    }
  }
  if (u == v) return u;
  for (int i = lg - 1; i >= 0; i--) {
    if (lcpa[u][i] && lcpa[u][i] != lcpa[v][i]) {
      u = lcpa[u][i];
      v = lcpa[v][i];
    }
  }
  return lcpa[u][0];
}
void prec() {
  for (int i = 1; i < lg; i++) {
    for (int j = 1; j <= n; j++) {
      if (!lcpa[j][i - 1]) continue;
      lcpa[j][i] = lcpa[lcpa[j][i - 1]][i - 1];
    }
  }
}
void dfs1(int u, int v) {
  int fool = 0;
  for (auto it : adj[u]) {
    if (it.first == v) continue;
    dfs1(it.first, u);
    fool += fools[it.first];
  }
  fools[u] += fool;
  ans[road[u]] = fools[u];
}
void solve() {
  int x, y;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    adj[x].push_back({y, i});
    adj[y].push_back({x, i});
  }
  dfs(1, 0, 1, 0);
  prec();
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    cin >> x >> y;
    fools[x]++;
    fools[y]++;
    fools[lcp(x, y)] -= 2;
  }
  dfs1(1, 0);
  for (int i = 1; i < n; i++) {
    cout << ans[i] << " ";
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1;
  while (t--) {
    solve();
  }
}
