#include <bits/stdc++.h>
using namespace std;
int n, a, b, m;
vector<int> g[100009];
pair<int, int> _v[100009];
int p[100009][21], L[100009], are[100009];
void dfs(int x, int par) {
  p[x][0] = par;
  L[x] = L[par] + 1;
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != par) dfs(g[x][i], x);
}
void dsf(int x, int par) {
  for (int i = 0; i < g[x].size(); i++)
    if (g[x][i] != par) dsf(g[x][i], x);
  are[par] += are[x];
}
void build() {
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= n; j++) p[j][i] = p[p[j][i - 1]][i - 1];
}
int LCA(int x, int y) {
  if (L[x] < L[y]) swap(x, y);
  for (int i = 20; i >= 0; i--)
    if (L[p[x][i]] >= L[y]) x = p[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (p[x][i] != 0 && p[x][i] != p[y][i]) x = p[x][i], y = p[y][i];
  return p[x][0];
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    _v[i] = {a, b};
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, 0);
  build();
  cin >> m;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    int lca = LCA(a, b);
    are[a]++, are[b]++, are[lca] -= 2;
  }
  dsf(1, 0);
  for (int i = 1; i < n; i++) {
    a = _v[i].first, b = _v[i].second;
    if (p[a][0] == b)
      printf("%d ", are[a]);
    else
      printf("%d ", are[b]);
  }
  return 0;
}
