#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 7;
const long long N = 1e5 + 7;
const long long md = 1e9 + 7;
vector<pair<long long, long long>> g[N];
vector<vector<long long>> up;
long long L, hu[N];
long long in_time[N];
long long out_time[N];
long long timer;
long long e[N];
void subTreeSum(long long from, long long p) {
  for (auto &to : g[from]) {
    if (to.first != p) {
      subTreeSum(to.first, from);
      e[to.second] += hu[to.first];
      hu[from] += hu[to.first];
    }
  }
}
void computeAncestors(long long from, long long par) {
  in_time[from] = ++timer;
  up[from][0] = par;
  for (long long i = 1; i <= L; i++) {
    up[from][i] = up[up[from][i - 1]][i - 1];
  }
  for (auto &to : g[from]) {
    if (to.first != par) computeAncestors(to.first, from);
  }
  out_time[from] = ++timer;
}
long long isAncestor(long long u, long long v) {
  return in_time[u] <= in_time[v] && out_time[u] >= out_time[v];
}
long long LCA(long long u, long long v) {
  if (isAncestor(u, v)) return u;
  if (isAncestor(v, u)) return v;
  for (long long i = L; i >= 0; i--) {
    if (!isAncestor(up[u][i], v)) {
      u = up[u][i];
    }
  }
  return up[u][0];
}
void initialize(long long n) {
  L = (long long)ceil(log2(n));
  up = vector<vector<long long>>(n + 1, vector<long long>(L + 1));
}
void sol() {
  long long n, q, u, v;
  cin >> n;
  for (long long i = 1; i < n; i++) {
    cin >> u >> v;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  initialize(n);
  computeAncestors(1, 1);
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> u >> v;
    hu[u]++;
    hu[v]++;
    hu[LCA(u, v)] -= 2;
  }
  subTreeSum(1, 1);
  for (long long i = 1; i < n; i++) {
    cout << e[i] << " ";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  while (T--) sol();
  return 0;
}
