#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 100;
const int LOG = 17 + 1;
int n, z[N], dep[N], pi[N][LOG], ans[N];
vector<pair<int, int> > adj[N];
inline void dfs(int v, int par = -1, int d = 0) {
  pi[v][0] = par;
  dep[v] = d;
  for (int i = 0; i < (int)adj[v].size(); i++)
    if (adj[v][i].first != par) dfs(adj[v][i].first, v, d + 1);
}
inline int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int j = LOG - 1; j >= 0; j--)
    if (pi[u][j] != -1 && dep[pi[u][j]] >= dep[v]) u = pi[u][j];
  if (u == v) return v;
  for (int j = LOG - 1; j >= 0; j--)
    if (pi[u][j] != pi[v][j]) u = pi[u][j], v = pi[v][j];
  return pi[u][0];
}
inline int solve(int v, int par = -1) {
  int res = z[v];
  for (int i = 0; i < (int)adj[v].size(); i++)
    if (adj[v][i].first != par) {
      ans[adj[v][i].second] = solve(adj[v][i].first, v);
      res += ans[adj[v][i].second];
    }
  return res;
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    adj[u].push_back(pair<int, int>(v, i));
    adj[v].push_back(pair<int, int>(u, i));
  }
  memset(pi, -1, sizeof pi);
  dfs(1);
  for (int j = 1; j < LOG; j++)
    for (int i = 1; i <= n; i++)
      pi[i][j] = (pi[i][j - 1] == -1) ? -1 : pi[pi[i][j - 1]][j - 1];
  memset(z, 0, sizeof z);
  int x, q;
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &u, &v);
    x = lca(u, v);
    z[x] -= 2;
    z[u]++;
    z[v]++;
  }
  ans[0] = solve(1);
  for (int i = 1; i < n; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
