#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  if (a >= mod) a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    if (res >= mod) res %= mod;
    a = a * a;
    if (a >= mod) a %= mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long n;
vector<long long> vec[100010];
long long P[100010][20];
long long T[100010];
long long L[100010];
void dfs(long long node, long long parent, long long level) {
  T[node] = parent;
  L[node] = level;
  for (int i = 0; i < vec[node].size(); i++) {
    if (vec[node][i] != parent) {
      dfs(vec[node][i], node, level + 1);
    }
  }
}
void preprocess() {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; 1 << j < n; j++) {
      P[i][j] = -1;
    }
  }
  for (i = 0; i < n; i++) {
    P[i][0] = T[i];
  }
  for (j = 1; 1 << j < n; j++)
    for (i = 0; i < n; i++)
      if (P[i][j - 1] != -1) P[i][j] = P[P[i][j - 1]][j - 1];
}
long long query(long long p, long long q) {
  long long i, j, tmp, log;
  if (L[p] < L[q]) tmp = p, p = q, q = tmp;
  for (log = 1; 1 << log <= L[p]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--)
    if (L[p] - (1 << i) >= L[q]) p = P[p][i];
  if (p == q) return p;
  for (i = log; i >= 0; i--)
    if (P[p][i] != -1 && P[p][i] != P[q][i]) p = P[p][i], q = P[q][i];
  return T[p];
}
long long dp[100010];
map<pair<long long, long long>, long long> my;
long long ansarr[1000100];
long long dfsagain(long long node, long long parent) {
  long long i, j, sum = 0, temp;
  for (i = 0; i < vec[node].size(); i++) {
    if (vec[node][i] != parent) {
      temp = dfsagain(vec[node][i], node);
      ansarr[my[make_pair(node, vec[node][i])]] = temp;
      sum += temp;
    }
  }
  return sum + dp[node];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long u, v, i, j;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    my[make_pair(u, v)] = i;
    my[make_pair(v, u)] = i;
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  dfs(0, -1, 1);
  preprocess();
  long long k;
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> u >> v;
    u--;
    v--;
    long long lca = query(u, v);
    dp[lca] -= 2;
    dp[u]++;
    dp[v]++;
  }
  dfsagain(0, -1);
  for (i = 0; i < n - 1; i++) cout << ansarr[i] << " ";
}
