#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 10, N = 2e5 + 10, mod = 1e9 + 7, lg = 20;
long long n, k, l, s[N], e[N], dis[N], par[lg][N];
map<pair<long long, long long>, long long> edge;
vector<long long> adj[N];
bool mark[N];
inline void dfs(long long v, long long p, long long d) {
  dis[v] = d;
  par[0][v] = p;
  for (int i = 1; i < lg; i++) par[i][v] = par[i - 1][par[i - 1][v]];
  for (auto u : adj[v])
    if (u != p) dfs(u, v, d + 1);
}
inline long long ipar(long long x, long long y) {
  for (int i = 0; i < lg; i++)
    if ((1 << i) & y) x = par[i][x];
  return x;
}
inline long long lca(long long x, long long y) {
  if (dis[x] > dis[y]) swap(x, y);
  y = ipar(y, dis[y] - dis[x]);
  if (x == y) return x;
  for (int i = lg - 1; i >= 0; i--) {
    if (par[i][x] == par[i][y])
      continue;
    else {
      x = par[i][x];
      y = par[i][y];
    }
  }
  return par[0][x];
}
inline void dfs2(long long v) {
  mark[v] = 1;
  for (auto u : adj[v])
    if (!mark[u]) {
      dfs2(u);
      e[edge[{v, u}]] = s[u];
      s[v] += s[u];
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long u, v;
  cin >> n;
  for (int i = 1; i < n; i -= -1) {
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
    edge[{u, v}] = edge[{v, u}] = i;
  }
  dfs(0, -1, 0);
  cin >> k;
  while (k--) {
    cin >> u >> v;
    l = lca(--u, --v);
    s[u]++;
    s[v]++;
    s[l] -= 2;
  }
  dfs2(0);
  for (int i = 1; i < n; i++) cout << e[i] << " ";
}
