#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int n, d[N], dp[N][20], arr[N], ans[N];
vector<vector<pair<int, int> > > g;
void dfs(int u, int p, int dep) {
  d[u] = dep;
  dp[u][0] = p;
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i].first;
    if (v == p) continue;
    dfs(v, u, dep + 1);
  }
}
int dfs(int u, int p) {
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i].first;
    if (v == p) continue;
    int t = dfs(v, u);
    ans[g[u][i].second] = t;
    arr[u] += t;
  }
  return arr[u];
}
int LCA(int a, int b) {
  if (d[b] > d[a]) swap(a, b);
  int k = 0;
  while ((1 << k) <= d[a]) k++;
  for (int i = k; i >= 0; --i)
    if (d[a] - (1 << i) >= d[b]) a = dp[a][i];
  if (a == b) return a;
  for (int i = k; i >= 0; --i)
    if (dp[a][i] != dp[b][i]) a = dp[a][i], b = dp[b][i];
  return dp[a][0];
}
int main() {
  scanf("%d", &n);
  g.resize(n);
  for (int x, y, i = 0; i < n - 1; ++i) {
    scanf("%d%d", &x, &y);
    x--, y--;
    g[x].push_back({y, i});
    g[y].push_back({x, i});
  }
  dfs(0, -1, 0);
  for (int k = 1; k <= 18; ++k)
    for (int i = 0; i < n; ++i)
      if (dp[i][k - 1] != -1)
        dp[i][k] = dp[dp[i][k - 1]][k - 1];
      else
        dp[i][k] = -1;
  int q, x, y;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &x, &y);
    x--, y--;
    int lca = LCA(x, y);
    arr[x]++;
    arr[lca] -= 2;
    arr[y]++;
  }
  dfs(0, -1);
  for (int i = 0; i < n - 1; ++i)
    printf("%d%c", ans[i], (i + 1 == n - 1) ? '\n' : ' ');
  return 0;
}
