#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1 << 20, MAXlgn = 20;
int n, par[MAXn], a[MAXn + 10][MAXlgn + 10], h[MAXn], ans[MAXn], cnt[MAXn];
bool mrk[MAXn];
vector<int> g[MAXn], e[MAXn];
void make_dfs(int v) {
  mrk[v] = true;
  for (int i = 0; i < g[v].size(); ++i) {
    int u = g[v][i];
    if (!mrk[u]) {
      par[u] = v;
      a[u][0] = v;
      int j = 1;
      while (a[u][j - 1] != -1 && j < MAXlgn)
        a[u][j] = a[a[u][j - 1]][j - 1], ++j;
      h[u] = h[v] + 1;
      make_dfs(u);
    }
  }
}
int make_equel_height(int v, int u) {
  if (h[v] == h[u]) return v;
  int j = MAXlgn;
  while (h[v] != h[u]) {
    if (a[v][j] == -1)
      --j;
    else {
      if (h[a[v][j]] < h[u])
        --j;
      else
        v = a[v][j];
    }
  }
  return v;
}
int find_LCA(int v, int u) {
  if (v == u) return v;
  int j = MAXlgn;
  while (par[v] != par[u]) {
    if (a[v][j] == -1 || a[u][j] == -1 || a[v][j] == a[u][j])
      --j;
    else
      v = a[v][j], u = a[u][j];
  }
  return par[v];
}
int dfs(int v) {
  int ret = 0;
  mrk[v] = true;
  for (int i = 0; i < g[v].size(); ++i)
    if (!mrk[g[v][i]]) {
      int u = g[v][i], edge = e[v][i];
      ans[edge] = dfs(u);
      ret += ans[edge];
    }
  ret += cnt[v];
  return ret;
}
int main() {
  cin >> n;
  fill(par, par + n, -1);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j <= MAXlgn; ++j) a[i][j] = -1;
  for (int i = 0; i + 1 < n; ++i) {
    int v, u;
    cin >> v >> u;
    --v, --u;
    g[v].push_back(u);
    g[u].push_back(v);
    e[v].push_back(i);
    e[u].push_back(i);
  }
  par[0] = -1;
  make_dfs(0);
  int T;
  cin >> T;
  for (int i = 0; i < T; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    ++cnt[x];
    ++cnt[y];
    if (h[x] < h[y])
      y = make_equel_height(y, x);
    else
      x = make_equel_height(x, y);
    cnt[find_LCA(x, y)] -= 2;
  }
  for (int i = 0; i < n; ++i) cerr << cnt[i] << " ";
  cerr << endl;
  fill(mrk, mrk + n, 0);
  dfs(0);
  for (int i = 0; i + 1 < n; ++i) cout << ans[i] << " ";
  cout << endl;
}
