#include <bits/stdc++.h>
using namespace std;
int n, m, at, i[100005], ta, tb, cnt[100005], ans[100005];
vector<int> y[100005], x[100005];
pair<int, int> z[19][100005 * 2];
void dfs(int a, int b, int c) {
  z[0][i[a] = at++] = make_pair(c, a);
  for (int d = 0; d < y[a].size(); d++)
    if (y[a][d] != b) {
      dfs(y[a][d], a, c + 1);
      z[0][at++] = make_pair(c, a);
    }
}
pair<int, int> f1(int a, int b, int c, int d) {
  if (a == ((1 << (c)) * (d)) && b == ((1 << (c)) * (d + 1))) return z[c][d];
  c--;
  d = d * 2 + 1;
  if (b <= ((1 << (c)) * (d))) return f1(a, b, c, d - 1);
  if (a >= ((1 << (c)) * (d))) return f1(a, b, c, d);
  return min(f1(a, ((1 << (c)) * (d)), c, d - 1),
             f1(((1 << (c)) * (d)), b, c, d));
}
int lca(int a, int b) {
  return f1(min(i[a], i[b]), max(i[a], i[b]) + 1, 18, 0).second;
}
void dfs1(int a, int b) {
  for (int c = 0; c < y[a].size(); c++)
    if (y[a][c] != b) {
      dfs1(y[a][c], a);
      cnt[a] += cnt[y[a][c]];
      ans[x[a][c]] = cnt[y[a][c]];
    }
}
int main() {
  scanf("%d", &n);
  for (int a = 1; a < n; a++) {
    scanf("%d%d", &ta, &tb);
    y[ta].push_back(tb), y[tb].push_back(ta);
    x[ta].push_back(a), x[tb].push_back(a);
  }
  dfs(1, 0, 0);
  for (int a = 1; a < 19; a++)
    for (int b = 0; ((1 << (a)) * (b)) < at; b++) {
      if (((1 << (a - 1)) * (b * 2 + 1)) < at)
        z[a][b] = min(z[a - 1][b * 2], z[a - 1][b * 2 + 1]);
      else
        z[a][b] = z[a - 1][b * 2];
    }
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &ta, &tb);
    cnt[ta]++, cnt[tb]++, cnt[lca(ta, tb)] -= 2;
  }
  dfs1(1, 0);
  for (int a = 1; a < n; a++) printf("%d%c", ans[a], a == n - 1 ? '\n' : ' ');
}
