#include <bits/stdc++.h>
using namespace std;
long long n, par[200007], depth[200007], fin[200007], ini[200007],
    p[200007][19];
vector<long long> g[200007];
map<pair<long long, long long>, long long> edge;
unordered_map<long long, long long> vertex;
unordered_map<long long, pair<long long, long long> > edges;
void preprocessLCA() {
  for (long long i = 1; i <= (n); ++i)
    for (long long j = 0; j < (19); ++j) p[i][j] = -1;
  for (long long i = 1; i <= (n); ++i) p[i][0] = par[i];
  for (long long j = 1; (1LL << (j)) < n; ++j)
    for (long long i = 1; i <= n; ++i)
      if (p[i][j - 1] != -1) p[i][j] = p[p[i][j - 1]][j - 1];
}
long long LCA(long long a, long long b) {
  if (depth[a] < depth[b]) swap(a, b);
  long long dis = (depth[a] - depth[b]);
  while (dis > 0)
    a = p[a][(63 - __builtin_clzll(dis))],
    dis -= (1LL << ((63 - __builtin_clzll(dis))));
  if (a == b) return b;
  for (long long j = 19 - 1; j >= 0; --j) {
    if ((p[a][j] != -1) && (p[a][j] != p[b][j])) a = p[a][j], b = p[b][j];
  }
  return par[a];
}
void DFStree(long long v) {
  for (auto u : g[v]) {
    if (u == par[v]) continue;
    par[u] = v;
    depth[u] = depth[v] + 1;
    vertex[edge[make_pair(v, u)]] = u;
    DFStree(u);
  }
}
void DFSsubtrees(long long v) {
  for (auto u : g[v]) {
    if (u == par[v]) continue;
    DFSsubtrees(u);
    ini[v] += ini[u];
    fin[v] += fin[u];
  }
}
void solve() {
  cin >> n;
  for (long long i = 1; i <= (n - 1); ++i) {
    long long a, b;
    cin >> a >> b;
    edges[i] = make_pair(a, b);
    edge[make_pair(a, b)] = edge[make_pair(b, a)] = i;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  DFStree(1);
  preprocessLCA();
  long long fools;
  cin >> fools;
  while (fools--) {
    long long a, b;
    cin >> a >> b;
    if (a == b) continue;
    long long l = LCA(a, b);
    ++ini[a];
    ++fin[b];
    --ini[l];
    --fin[l];
  }
  DFSsubtrees(1);
  for (long long i = 1; i <= (n - 1); ++i) {
    long long v = vertex[edge[edges[i]]];
    cout << ini[v] + fin[v] << " ";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}
