#include <bits/stdc++.h>
using namespace std;
int n, k, anc[100010][20] = {}, tin[100010], tout[100010], dp[100010] = {},
          T = 0;
struct edge {
  int v, u, ans;
  inline int get(int t) { return t != v ? v : u; }
};
vector<edge> edges(100010);
vector<int> g[100010];
void Mlca(int v, int p) {
  tin[v] = T++;
  anc[v][0] = p;
  for (int i = 1; i < 20; ++i) anc[v][i] = anc[anc[v][i - 1]][i - 1];
  for (auto &num : g[v]) {
    int u = edges[num].get(v);
    if (u != p) Mlca(u, v);
  }
  tout[v] = T++;
}
inline bool isupper(int a, int b) {
  return tin[a] <= tin[b] && tout[a] >= tout[b];
}
inline int lca(int a, int b) {
  if (isupper(a, b)) return a;
  if (isupper(b, a)) return b;
  for (int i = 19; i >= 0; --i)
    if (!isupper(anc[a][i], b) && anc[a][i] != 0) a = anc[a][i];
  return anc[a][0];
}
int dfs(int v, int p) {
  int now = dp[v], x = 0;
  for (auto &num : g[v]) {
    int u = edges[num].get(v);
    if (u != p)
      now += dfs(u, v);
    else
      x = num;
  }
  edges[x].ans += now;
  return now;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int r1, r2;
    cin >> r1 >> r2;
    g[r1].push_back(i);
    g[r2].push_back(i);
    edges[i] = {r1, r2, 0};
  }
  Mlca(1, 0);
  cin >> k;
  for (int i = 1; i <= k; ++i) {
    int r1, r2;
    cin >> r1 >> r2;
    int r3 = lca(r1, r2);
    ++dp[r1], ++dp[r2], dp[r3] -= 2;
  }
  dfs(1, 0);
  for (int i = 1; i < n; ++i) cout << edges[i].ans << ' ';
}
