#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 100 + 10, maxl = 20;
int par[maxn][maxl], h[maxn];
int n, k;
vector<int> adj[maxn];
int dp[maxn], ans[maxn];
pair<int, int> edge[maxn];
void dfs1(int v, int p) {
  par[v][0] = p;
  for (int i = 1; i < maxl and par[v][i - 1] != -1; i++) {
    par[v][i] = par[par[v][i - 1]][i - 1];
  }
  for (auto u : adj[v]) {
    if (u != p) {
      h[u] = h[v] + 1;
      dfs1(u, v);
    }
  }
}
void dfs2(int v) {
  ans[v] += dp[v];
  for (auto u : adj[v]) {
    if (u != par[v][0]) {
      dfs2(u);
      ans[v] += ans[u];
    }
  }
}
int lca(int v, int u) {
  if (h[u] < h[v]) {
    swap(u, v);
  }
  for (int i = 0; h[u] ^ h[v]; i++) {
    if (((h[u] - h[v]) >> i) & 1) {
      u = par[u][i];
    }
  }
  if (u == v) {
    return u;
  }
  for (int i = maxl - 1; i + 1; i--) {
    if (par[u][i] != par[v][i]) {
      u = par[u][i], v = par[v][i];
    }
  }
  return par[u][0];
}
int main() {
  std::memset(par, -1, sizeof par);
  cin >> n;
  for (int i = 1, a, b; i < n; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
    edge[i] = make_pair(a, b);
  }
  dfs1(1, -1);
  cin >> k;
  for (int i = 0, a, b; i < k; i++) {
    cin >> a >> b;
    dp[a]++;
    dp[b]++;
    dp[lca(a, b)] -= 2;
  }
  dfs2(1);
  for (int i = 1; i < n; i++) {
    if (h[edge[i].first] > h[edge[i].second]) {
      cout << ans[edge[i].first] << " ";
    } else {
      cout << ans[edge[i].second] << " ";
    }
  }
  cout << endl;
}
