#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool smin(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}
template <typename T>
inline bool smax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const long long N = 1e5 + 100, lg = 22;
long long n, k, add[N], h[N];
vector<pair<long long, long long> > adj[N];
long long par[N][lg];
void dfs(long long v = 1, long long p = -1, long long dep = 0) {
  if (v != 1) {
    par[v][0] = p;
    for (long long i = 1; i < lg; i++) par[v][i] = par[par[v][i - 1]][i - 1];
  } else {
    for (long long i = 0; i < lg; i++) par[v][i] = v;
  }
  h[v] = dep;
  for (auto u : adj[v])
    if (u.first != p) dfs(u.first, v, dep + 1);
}
long long getPar(long long v, long long k) {
  for (long long i = lg - 1; i >= 0; i--)
    if (k >> i & 1) v = par[v][i];
  return v;
}
long long lca(long long u, long long v) {
  if (h[u] > h[v]) swap(u, v);
  v = getPar(v, h[v] - h[u]);
  if (u == v) return v;
  for (long long i = lg - 1; i >= 0; i--) {
    if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
  }
  return par[v][0];
}
long long ans[N];
long long calc(long long v = 1, long long p = -1, long long want = -1) {
  long long res = add[v];
  for (auto u : adj[v]) {
    if (u.first == p) continue;
    res += calc(u.first, v, u.second);
  }
  if (want != -1) ans[want] = res;
  return res;
}
int32_t main() {
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    adj[v].push_back({u, i}), adj[u].push_back({v, i});
  }
  dfs();
  cin >> k;
  while (k--) {
    long long u, v;
    cin >> u >> v;
    long long l = lca(u, v);
    add[u]++, add[v]++, add[l] -= 2;
  };
  calc();
  for (long long i = 0; i < n - 1; i++) cout << ans[i] << ' ';
}
