#include <bits/stdc++.h>
using namespace std;
int st[100100][20];
vector<int> graph[100100], ind[100100];
int lev[100100];
int t[100100], l[100100], lg[100100];
int s[100100];
void blg(int n) {
  lg[0] = -1;
  for (int i = 0; i < n; ++i) lg[i + 1] = lg[i] + !(i & (i + 1));
}
void dfs(int u, int p, int l) {
  st[u][0] = p;
  for (int i = 1; (1 << i) <= l; ++i) st[u][i] = st[st[u][i - 1]][i - 1];
  lev[u] = l;
  for (int v : graph[u])
    if (v != p) dfs(v, u, l + 1);
}
int getParent(int u, int d) {
  if (lev[u] < d) return -1;
  for (int i = d; i; i -= i & -i) u = st[u][lg[i & -i]];
  return u;
}
int LCA(int x, int y) {
  if (lev[x] < lev[y]) swap(x, y);
  int d = lev[x] - lev[y];
  for (int i = 0; d; i++) {
    if (d & 1) x = st[x][i];
    d >>= 1;
  }
  if (x == y) return x;
  int l = log2(lev[x]);
  for (int i = l; i >= 0; i--) {
    if (st[x][i] != st[y][i]) x = st[x][i], y = st[y][i];
  }
  return st[x][0];
}
int solve(int u, int p) {
  int y = l[u] - t[u];
  for (int j = 0; j < graph[u].size(); ++j) {
    int v = graph[u][j];
    if (v != p) {
      y += s[ind[u][j]] = solve(v, u);
    }
  }
  return y;
}
int main() {
  int n, k, x, y;
  cin >> n;
  blg(n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &x, &y);
    graph[x].push_back(y), graph[y].push_back(x);
    ind[x].push_back(i);
    ind[y].push_back(i);
  }
  dfs(1, 1, 0);
  cin >> k;
  while (k--) {
    scanf("%d%d", &x, &y);
    t[LCA(x, y)] += 2;
    l[x]++, l[y]++;
  }
  solve(1, 0);
  for (int i = 1; i < n; ++i) cout << s[i] << " ";
}
