#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, MAX = INT_MAX, MAXN = 1e5 + 5;
template <typename T>
istream &operator>>(istream &in, vector<T> &v) {
  for (auto &i : v) cin >> i;
  return in;
}
template <typename T>
istream &operator>>(istream &in, pair<T, T> &p) {
  cin >> p.first >> p.second;
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &v) {
  for (auto &i : v) cout << i << " ";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, pair<T, T> &p) {
  cout << p.first << " " << p.second << " ";
  return out;
}
vector<vector<long long>> adj(MAXN), par(MAXN, vector<long long>(19));
vector<long long> lvl(MAXN), ans(MAXN);
void dfs(long long u, long long p) {
  par[u][0] = p;
  lvl[u] = lvl[p] + 1;
  for (auto v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
  }
}
long long lca(long long u, long long v) {
  if (lvl[u] > lvl[v]) swap(u, v);
  long long diff = lvl[v] - lvl[u];
  for (long long i = 0; i < 19; i++)
    if ((diff >> i) & 1) v = par[v][i];
  if (u == v) return u;
  for (long long i = 18; i >= 0; i--) {
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  }
  return par[u][0];
}
void dfs2(long long u, long long p) {
  for (auto v : adj[u]) {
    if (v == p) continue;
    dfs2(v, u);
    ans[u] += ans[v];
  }
}
void solve() {
  long long n, u, v, i, k;
  cin >> n;
  vector<pair<long long, long long>> edges;
  for (i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    edges.push_back({u, v});
  }
  dfs(1, 0);
  for (i = 1; i < 19; i++) {
    for (long long j = 1; j <= n; j++) par[j][i] = par[par[j][i - 1]][i - 1];
  }
  cin >> k;
  while (k--) {
    cin >> u >> v;
    long long l = lca(u, v);
    ans[u]++;
    ans[v]++;
    ans[l] -= 2;
  }
  dfs2(1, 0);
  for (auto edge : edges) {
    u = edge.first, v = edge.second;
    if (lvl[u] > lvl[v]) swap(u, v);
    cout << ans[v] << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
