#include <bits/stdc++.h>
using namespace std;
long long n, k, a, b, par[100100], Ancestor[100100][40], Depth[100100],
    pre[100100], Answer[100100];
vector<pair<int, int> > v[100100];
void DFS(int x, int p, int L) {
  par[x] = p;
  Depth[x] = L;
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i].first != p) DFS(v[x][i].first, x, L + 1);
}
void BuildAncestor() {
  for (int i = 1; i <= n; i++) Ancestor[i][0] = par[i];
  for (int i = 1; i <= 30; i++) {
    for (int j = 1; j <= n; j++) {
      Ancestor[j][i] = Ancestor[Ancestor[j][i - 1]][i - 1];
    }
  }
}
int LCA(int a, int b) {
  int x = max(Depth[a], Depth[b]) - min(Depth[a], Depth[b]);
  if (Depth[a] > Depth[b]) swap(a, b);
  for (int i = 30; i >= 0; i--)
    if ((1LL << i) <= x) b = Ancestor[b][i], x -= (1 << i);
  for (int i = 30; i >= 0; i--) {
    if (Ancestor[a][i] != Ancestor[b][i]) {
      a = Ancestor[a][i];
      b = Ancestor[b][i];
    }
  }
  if (a != b)
    return par[a];
  else
    return a;
}
void DFS2(int x, int p) {
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i].first != p) {
      DFS2(v[x][i].first, x);
      pre[x] += pre[v[x][i].first];
    }
  }
}
void DFS3(int x, int p) {
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i].first != p) {
      Answer[v[x][i].second] = pre[v[x][i].first];
      DFS3(v[x][i].first, x);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back({y, i});
    v[y].push_back({x, i});
  }
  DFS(1, -1, 0);
  BuildAncestor();
  cin >> k;
  for (int i = 0; i < k; i++) {
    scanf("%I64d%I64d", &a, &b);
    if (LCA(a, b) != a && LCA(a, b) != b) {
      pre[LCA(a, b)] -= 2;
      pre[a]++;
      pre[b]++;
    } else if (LCA(a, b) == a) {
      pre[LCA(a, b)]--;
      pre[b]++;
    } else {
      pre[LCA(a, b)]--;
      pre[a]++;
    }
  }
  DFS2(1, -1);
  DFS3(1, -1);
  for (int i = 0; i < n - 1; i++) printf("%I64d ", Answer[i]);
  return 0;
}
