#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
map<pair<int, int>, int> cnt;
queue<pair<int, int> > q;
vector<int> adj[N];
pair<int, int> node[N];
int dp[N][20];
int mark[N], L[N];
int n, u, v, k, i, j;
void dfs(int cur, int par) {
  dp[cur][0] = par;
  L[cur] = L[par] + 1;
  node[cur - 1] = make_pair((L[cur]), (cur));
  for (int x : adj[cur])
    if (x != par) dfs(x, cur);
}
int lca(int u, int v) {
  if (L[u] > L[v]) u ^= v ^= u ^= v;
  int diff = L[v] - L[u];
  for (i = 1, j = 0; i <= n; i <<= 1, ++j)
    if (diff & i) v = dp[v][j];
  while (u != v && j != -1) {
    if (dp[u][j] != dp[v][j] || !j)
      u = dp[u][j], v = dp[v][j];
    else
      j--;
  }
  return u;
}
void up(int cur) {
  int par = dp[cur][0];
  mark[par] += mark[cur];
  cnt[make_pair((cur), (par))] += mark[cur];
  cnt[make_pair((par), (cur))] += mark[cur];
  mark[cur] = 0;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i < n; ++i) {
    scanf("%d%d", &u, &v);
    q.push(make_pair((u), (v)));
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  L[0] = -1;
  dfs(1, 0);
  for (i = 1; (1 << i) < n; ++i)
    for (j = 1; j <= n; ++j) dp[j][i] = dp[dp[j][i - 1]][i - 1];
  scanf("%d", &k);
  while (k--) {
    scanf("%d%d", &u, &v);
    int x = lca(u, v);
    mark[u]++;
    mark[v]++;
    mark[x] -= 2;
  }
  sort(node, node + n);
  reverse(node, node + n);
  for (i = 0; i < n; ++i)
    if (mark[node[i].second] > 0) up(node[i].second);
  for (pair<int, int> a = q.front(); !q.empty(); q.pop(), a = q.front())
    printf("%d ", cnt[a]);
  puts("");
}
