#include <bits/stdc++.h>
using namespace std;
const long long N = 200002;
long long n, k, sza[N], szb[N], par[N][20], h[N];
vector<long long> g[N];
vector<pair<long long, long long>> e;
map<pair<long long, long long>, long long> res;
void dfs(long long v, long long p) {
  par[v][0] = p;
  h[v] = h[p] + 1;
  for (long long i = 1; i < 20; ++i) par[v][i] = par[par[v][i - 1]][i - 1];
  for (long long u : g[v]) {
    if (u != p) {
      dfs(u, v);
    }
  }
}
long long up(long long v, long long d) {
  for (long long i = 19; i >= 0; i--) {
    if ((1 << i) <= d) {
      v = par[v][i];
      d -= (1 << i);
    }
  }
  return v;
}
long long lca(long long v, long long u) {
  if (h[v] > h[u]) swap(v, u);
  u = up(u, h[u] - h[v]);
  for (long long i = 19; i >= 0; i--) {
    if (par[v][i] != par[u][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  }
  if (u == v) return v;
  return par[v][0];
}
void init(long long v, long long p) {
  for (long long u : g[v]) {
    if (u != p) {
      init(u, v);
      sza[v] += sza[u];
      szb[v] += szb[u];
    }
  }
  for (long long u : g[v]) {
    if (u != p) {
      res[{u, v}] = sza[u] - szb[u];
      res[{v, u}] = sza[u] - szb[u];
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i + 1 < n; ++i) {
    long long v, u;
    cin >> v >> u;
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
    e.push_back({u, v});
  }
  dfs(0, 0);
  cin >> k;
  for (long long i = 0; i < k; ++i) {
    long long v, u;
    cin >> v >> u;
    v--;
    u--;
    sza[v]++;
    sza[u]++;
    szb[lca(v, u)] += 2;
  }
  init(0, 0);
  for (pair<long long, long long> p : e) cout << res[p] << ' ';
}
