#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 1e5 + 5;
int par[N][18];
int level[N], ans[N], w[N], val[N];
vector<pair<int, int>> E[N];
void dfs(int a, int lvl, int p) {
  level[a] = lvl;
  for (auto e : E[a]) {
    if (e.first == p) continue;
    par[e.first][0] = a;
    w[e.first] = e.second;
    dfs(e.first, lvl + 1, a);
  }
}
int lca(int a, int b) {
  if (level[a] < level[b]) swap(a, b);
  int d = level[a] - level[b];
  for (int i = 0; i < 17; i++)
    if (d >> i & 1) a = par[a][i];
  if (a == b) return a;
  for (int i = 16; i >= 0; i--) {
    if (par[a][i] != par[b][i]) {
      a = par[a][i];
      b = par[b][i];
    }
  }
  return par[a][0];
}
void foo(int a, int p) {
  for (auto e : E[a]) {
    if (e.first == p) continue;
    foo(e.first, a);
    val[a] += val[e.first];
  }
  if (val[a] > 0) {
    ans[w[a]] += val[a];
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    E[a].emplace_back(b, i);
    E[b].emplace_back(a, i);
  }
  memset(par, -1, sizeof par);
  dfs(1, 0, -1);
  for (int lg = 1; lg < 17; lg++) {
    for (int i = 1; i <= n; i++) {
      if (par[i][lg - 1] != -1) {
        par[i][lg] = par[par[i][lg - 1]][lg - 1];
      }
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    int c = lca(a, b);
    val[c] -= 2;
    val[a]++;
    val[b]++;
  }
  foo(1, -1);
  for (int i = 0; i < n - 1; i++) cout << ans[i] << ' ';
}
