#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long powm(long long base, long long exp, long long mod = 1000000007) {
  base %= mod;
  long long ans = 1;
  while (exp) {
    if (exp & 1LL) ans = (ans * base) % mod;
    exp >>= 1LL, base = (base * base) % mod;
  }
  return ans;
}
vector<long long> ed[100005];
vector<long long> a[100005];
long long p[100005];
long long L[100005];
long long n;
void dfsL(int x, int h) {
  if (L[x] != -1) return;
  L[x] = h;
  for (auto it : ed[x]) {
    if (L[it] != -1) continue;
    p[it] = x;
    dfsL(it, h + 1);
  }
}
long long log_2(long long x) {
  long long temp = 0;
  for (; (1 << temp) < n; temp++)
    ;
  return temp;
}
long long P[100005][40];
map<pair<long long, long long>, long long> m;
void preLCA(int n) {
  for (int i = 1; i <= n; i++) {
    for (int j = 0; 1 << j < n; j++) {
      P[i][j] = -1;
    }
  }
  for (int i = 1; i <= n; i++) {
    P[i][0] = p[i];
  }
  for (int i = 1; 1 << i < n; i++) {
    for (int j = 1; j <= n; j++) {
      if (P[j][i - 1] != -1) P[j][i] = P[P[j][i - 1]][i - 1];
    }
  }
}
long long lca(long long x, long long y, long long n) {
  if (L[x] < L[y]) swap(x, y);
  for (int i = log_2(n); i >= 0; i--) {
    if (P[x][i] != -1)
      if (L[P[x][i]] >= L[y]) x = P[x][i];
  }
  if (x == y) return x;
  for (int i = log_2(n); i >= 0; i--) {
    if (P[x][i] != -1 && P[x][i] != P[y][i]) {
      x = P[x][i];
      y = P[y][i];
    }
  }
  return p[y];
}
int v[100005];
int k[100005];
int b[100005];
long long ans[100005];
void dfs(int x) {
  if (v[x]) return;
  v[x] = 1;
  b[x] = 0;
  for (auto it : ed[x]) {
    if (v[it]) continue;
    dfs(it);
    long long idx = m[{x, it}];
    ans[idx] = b[it];
    for (auto t : a[it]) {
      long long lc = lca(t, it, n);
      if (L[lc] <= L[x]) {
        ans[idx]++;
        k[lc]++;
      }
    }
    ans[idx] -= k[it];
    b[x] += ans[idx];
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    ed[u].push_back(v);
    ed[v].push_back(u);
    m[{u, v}] = m[{v, u}] = i;
  }
  long long k;
  cin >> k;
  for (long long i = 1; i <= k; i++) {
    long long x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  memset(L, -1, sizeof(L));
  dfsL(1, 0);
  preLCA(n);
  dfs(1);
  for (int i = 1; i < n; i++) cout << ans[i] << " ";
  cout << '\n';
}
