#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG = 20;
int n, m, k, u, v, x, y, t, a, b;
int h[MAXN];
int ans[MAXN];
int par[MAXN][LOG];
pair<int, int> E[MAXN];
vector<int> G[MAXN];
void dfs(int node, int p) {
  h[node] = h[p] + 1;
  par[node][0] = p;
  for (int i = 1; i < LOG; i++) par[node][i] = par[par[node][i - 1]][i - 1];
  for (int v : G[node])
    if (v != p) dfs(v, node);
}
int dfs2(int node, int p) {
  for (int i : G[node])
    if (i != p) ans[node] += dfs2(i, node);
  return ans[node];
}
int lca(int x, int y) {
  if (h[x] > h[y]) swap(x, y);
  for (int i = 0; i < LOG; i++)
    if ((1 << i) & (h[y] - h[x])) y = par[y][i];
  for (int i = LOG - 1; i >= 0; i--)
    if (par[x][i] != par[y][i]) {
      x = par[x][i];
      y = par[y][i];
    }
  if (x != y) x = par[x][0];
  return x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    cin >> u >> v;
    E[i] = {u, v};
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  cin >> k;
  while (k--) {
    cin >> u >> v;
    ans[u]++;
    ans[v]++;
    ans[lca(u, v)] -= 2;
  }
  dfs2(1, 0);
  for (int i = 1; i <= n - 1; i++) {
    int v = E[i].first, u = E[i].second;
    if (h[u] < h[v])
      cout << ans[v] << ' ';
    else
      cout << ans[u] << ' ';
  }
  return 0;
}
