#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const long long INFL = (long long)9e18;
const int MAXINT = ((~0) ^ (1 << 31));
const long long MAXLL = ((~0) ^ ((long long)1 << 63));
template <class T>
inline T pow2(T a) {
  return a * a;
}
template <class T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, true) : false;
}
template <class T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, true) : false;
}
const int maxn = 2e5;
long long n, q, v, u, par[maxn][40], mark[maxn], l[maxn], valpar[maxn],
    lc[maxn];
vector<long long> g[maxn];
map<pair<long long, long long>, long long> mp;
pair<long long, long long> e[maxn];
void findpar(long long w, long long h) {
  mark[w] = 1;
  l[w] = h;
  for (int i = 0; i < g[w].size(); i++) {
    if (!mark[g[w][i]]) {
      par[g[w][i]][0] = w;
      for (int j = 1; j < 30; j++)
        par[g[w][i]][j] = par[par[g[w][i]][j - 1]][j - 1];
      findpar(g[w][i], h + 1);
    }
  }
}
long long getpar(long long w, long long h) {
  long long t = 0;
  while (h > 0) {
    if (h % 2 != 0) w = par[w][t];
    h /= 2;
    t++;
  }
  return w;
}
long long lca(long long v, long long u) {
  if (l[v] < l[u]) swap(u, v);
  v = getpar(v, l[v] - l[u]);
  if (v == u) return v;
  for (int i = 30; i >= 0; i--) {
    if (par[v][i] != par[u][i]) {
      v = par[v][i];
      u = par[u][i];
    }
  }
  return par[v][0];
}
long long dfs(long long w) {
  mark[w] = 1;
  long long t = lc[w];
  for (int i = 0; i < g[w].size(); i++) {
    if (!mark[g[w][i]]) {
      mp[{w, g[w][i]}] = dfs(g[w][i]);
      mp[{g[w][i], w}] = mp[{w, g[w][i]}];
      t += mp[{g[w][i], w}];
    }
  }
  return t - valpar[w];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> v >> u;
    g[u].push_back(v);
    g[v].push_back(u);
    e[i].first = v;
    e[i].second = u;
  }
  findpar(1, 0);
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> v >> u;
    long long w = lca(v, u);
    valpar[w] += 2;
    lc[v]++;
    lc[u]++;
  }
  memset(mark, 0, sizeof mark);
  dfs(1);
  for (int i = 0; i < n - 1; i++)
    cout << (mp[{e[i].first, e[i].second}] + mp[{e[i].second, e[i].first}]) / 2
         << " ";
}
