#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 9;
const long long MOD = 1e9 + 7;
const long long INF = 1e15 + 6;
const int lg = 22;
int N, Q, u, v;
vector<int> g[MAXN];
vector<int> edge[MAXN];
int cnt[MAXN];
int ans[MAXN];
int timer;
int vis[MAXN];
int tin[MAXN], tout[MAXN];
int par[MAXN][lg + 2];
inline void go(int node, int from = 0) {
  tin[node] = ++timer;
  par[node][0] = from;
  for (int i = 1; i <= lg; ++i) par[node][i] = par[par[node][i - 1]][i - 1];
  for (int i = 0; i < (int)g[node].size(); ++i)
    if (g[node][i] != from) go(g[node][i], node);
  tout[node] = ++timer;
}
inline bool IsAnc(int A, int B) {
  return (tin[A] <= tin[B] && tout[A] >= tout[B]);
}
inline int lca(int A, int B) {
  if (IsAnc(A, B)) return A;
  if (IsAnc(B, A)) return B;
  for (int lev = lg; lev >= 0; --lev)
    if ((par[A][lev] > 0) && (!IsAnc(par[A][lev], B))) A = par[A][lev];
  return par[A][0];
}
inline int dfs(int node, int from = 0, int edgeIdx = 200000) {
  int ret = 0;
  for (int i = 0; i < (int)g[node].size(); ++i) {
    int to = g[node][i];
    if (to == from) continue;
    ret += dfs(to, node, edge[node][i]);
  }
  return ans[edgeIdx] = ret + cnt[node];
}
int main() {
  memset(cnt, 0, sizeof(cnt));
  memset(ans, 0, sizeof(ans));
  memset(vis, false, sizeof(vis));
  scanf("%d", &N);
  for (int i = 0; i < N - 1; ++i) {
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    edge[u].push_back(i);
    edge[v].push_back(i);
  }
  go(1);
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d %d", &u, &v);
    cnt[u]++;
    cnt[v]++;
    cnt[lca(u, v)] -= 2;
  }
  dfs(1);
  for (int i = 0; i < N - 1; ++i) printf("%d ", ans[i]);
  return 0;
}
