#include <bits/stdc++.h>
using namespace std;
const int L = 18;
int up[200010][L + 4];
vector<vector<int>> g;
vector<int> cnt;
vector<int> tin, tout, d;
map<pair<int, int>, int> cst;
int timer = 0;
void dfs(int v, int p = 0, int dep = 0) {
  tin[v] = ++timer;
  up[v][0] = p;
  d[v] = dep;
  for (int i = 1; i <= L; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  for (auto to : g[v]) {
    if (to != p) {
      dfs(to, v, dep + 1);
    }
  }
  tout[v] = ++timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = L; i >= 0; --i)
    if (!upper(up[a][i], b)) a = up[a][i];
  return up[a][0];
}
int dist(int a, int b) { return d[a] + d[b] - 2 * d[lca(a, b)]; }
int solve(int v, int p = -1) {
  int res = cnt[v];
  for (auto to : g[v]) {
    if (to != p) {
      int cur = solve(to, v);
      cst[{min(v, to), max(v, to)}] = cur;
      res += cur;
    }
  }
  return res;
}
signed main() {
  std::ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  tin.resize(n);
  tout.resize(n);
  g.resize(n);
  d.resize(n);
  cnt.resize(n);
  vector<pair<int, int>> ed;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
    ed.push_back({a, b});
  }
  int m;
  cin >> m;
  dfs(0);
  while (m--) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    int lc = lca(a, b);
    cnt[a]++, cnt[b]++;
    cnt[lc] -= 2;
  }
  solve(0);
  for (int i = 0; i < n - 1; ++i) {
    cout
        << cst[{min(ed[i].first, ed[i].second), max(ed[i].first, ed[i].second)}]
        << ' ';
  }
  return 0;
}
