#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long N = 1e5 + 30, Mod = 1e9 + 7;
const long long SQ = 330;
const long long LOG = 23;
long long P[LOG][N], Cnt[N], Ans[N], H[N], n, k;
vector<pair<long long, long long> > G[N];
bitset<N> M;
void DFS(long long v = 1, long long par = 0, long long h = 0) {
  H[v] = h;
  M[v] = true;
  for (pair<long long, long long> u : G[v])
    if (u.first != par and !M[u.first])
      P[0][u.first] = v, DFS(u.first, v, h + 1);
}
long long Up(long long v, long long h) {
  for (int i = LOG - 1; i >= 0; i--) {
    if (h >= (1 << i)) {
      h -= 1 << i;
      v = P[i][v];
    }
  }
  return v;
}
long long LCA(long long v, long long u) {
  if (u == v) return v;
  if (H[v] < H[u]) swap(v, u);
  v = Up(v, H[v] - H[u]);
  if (v == u) return v;
  for (int i = LOG - 1; i >= 0; i--) {
    if (P[i][v] != P[i][u]) {
      v = P[i][v];
      u = P[i][u];
    }
  }
  return P[0][v];
}
long long Calc(long long v = 1, long long par = 0) {
  long long res = Cnt[v];
  for (pair<long long, long long> u : G[v]) {
    if (u.first != par) {
      long long t = Calc(u.first, v);
      Ans[u.second] = t;
      res += t;
    }
  }
  return res;
}
void Query(long long v, long long u) {
  long long w = LCA(v, u);
  if (w == v or w == u) {
    if (H[u] > H[v]) swap(v, u);
    Cnt[v]++;
    Cnt[u]--;
  } else {
    Cnt[v]++;
    Cnt[u]++;
    Cnt[w] -= 2;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0, v, u; i < n - 1; i++) {
    cin >> v >> u;
    G[v].push_back({u, i + 1});
    G[u].push_back({v, i + 1});
  }
  DFS();
  for (int i = 1; i < LOG; i++)
    for (int j = 1; j <= n; j++) P[i][j] = P[i - 1][P[i - 1][j]];
  cin >> k;
  while (k--) {
    long long v, u;
    cin >> v >> u;
    Query(v, u);
  }
  Calc();
  for (int i = 1; i < n; i++) cout << Ans[i] << ' ';
  cout << endl;
  return (0);
}
