#include <bits/stdc++.h>
using namespace std;
template <typename T>
T Abs(T first) {
  return (first < 0 ? -first : first);
}
template <typename T>
T Sqr(T first) {
  return (first * first);
}
const int INF = (int)1e9;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);
int root[100005], par[100005], lca[100005] = {0}, ans[100005],
                               done[100005] = {0};
vector<int> con[100005], foo[100005];
void Make(int i) { root[i] = i; }
int Find(int i) {
  if (root[i] == i) return (i);
  return (root[i] = Find(root[i]));
}
void Merge(int i, int j) {
  int ri = Find(i), rj = Find(j);
  root[rj] = ri;
}
void LCA(int i) {
  int j, k;
  Make(i);
  ans[i] = 0;
  for (j = 0; j < int(int((con[i]).size())); j++)
    if ((k = con[i][j]) != par[i]) {
      par[k] = i;
      LCA(k);
      Merge(i, k);
      ans[i] += ans[k];
    }
  for (j = 0; j < int(int((foo[i]).size())); j++)
    if (done[k = foo[i][j]]) lca[Find(k)]++;
  ans[i] += int((foo[i]).size());
  ans[i] -= lca[i] * 2;
  done[i] = 1;
}
int main() {
  if (0) freopen("in.txt", "r", stdin);
  int N, M;
  int i, j, k;
  static pair<int, int> edge[100005];
  scanf("%d", &N);
  for (i = 0; i < int(N - 1); i++) {
    scanf("%d%d", &j, &k);
    edge[i] = make_pair(j, k);
    con[j].push_back(k);
    con[k].push_back(j);
  }
  scanf("%d", &M);
  for (i = 0; i < int(M); i++) {
    scanf("%d%d", &j, &k);
    if (j == k) continue;
    foo[j].push_back(k);
    foo[k].push_back(j);
  }
  memset(par, -1, sizeof(par));
  par[1] = 0;
  LCA(1);
  for (i = 0; i < int(N - 1); i++) {
    j = edge[i].first, k = edge[i].second;
    if (par[j] == k) swap(j, k);
    printf("%d%c", ans[k], (i == N - 2 ? '\n' : ' '));
  }
  return (0);
}
