#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100007;
int n, logn = 0;
vector<pair<int, int> > e[MAX_N];
int h[MAX_N], t[MAX_N], p[MAX_N][22], c[MAX_N], f[MAX_N];
void init_lca(int u) {
  for (int i = int(1); i <= int(logn); ++i)
    if (h[u] - (1 << i) > 0)
      p[u][i] = p[p[u][i - 1]][i - 1];
    else
      p[u][i] = -1;
  for (int i = 0; i < int(int(e[u].size())); ++i) {
    int v = e[u][i].first;
    if (p[v][0] == 0) {
      p[v][0] = u;
      h[v] = h[u] + 1;
      t[v] = e[u][i].second;
      init_lca(v);
    }
  }
}
int lca(int u, int v) {
  if (h[u] > h[v]) return lca(v, u);
  if (h[u] < h[v])
    for (int i = int(logn); i >= int(0); --i)
      if (h[v] - (1 << i) >= h[u]) v = p[v][i];
  if (u == v) return u;
  for (int i = int(logn); i >= int(0); --i)
    if (p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  return p[u][0];
}
int cal_f(int u) {
  f[t[u]] = c[u];
  for (int i = 0; i < int(int(e[u].size())); ++i) {
    int v = e[u][i].first;
    if (p[v][0] == u) f[t[u]] += cal_f(v);
  }
  return f[t[u]];
}
int main() {
  int x, y, k;
  cin >> n;
  for (int i = int(1); i <= int(n - 1); ++i) {
    scanf("%d%d", &x, &y);
    e[x].push_back((make_pair((y), (i))));
    e[y].push_back((make_pair((x), (i))));
  }
  while (1 << (logn + 1) <= n) ++logn;
  for (int i = int(2); i <= int(n); ++i) p[i][0] = 0;
  h[1] = 1;
  p[1][0] = -1;
  t[1] = 0;
  init_lca(1);
  memset(c, (0), sizeof(c));
  cin >> k;
  for (int i = 0; i < int(k); ++i) {
    scanf("%d%d", &x, &y);
    ++c[x];
    ++c[y];
    c[lca(x, y)] -= 2;
  }
  cal_f(1);
  for (int i = int(1); i <= int(n - 1); ++i) printf("%d ", f[i]);
  return 0;
}
