#include <bits/stdc++.h>
using namespace std;
int n, k, sprs[100005][64], lvl[100005], pfx[100005], cur[100005], ans[100005];
pair<int, int> par[100005];
vector<pair<int, int> > v[100005];
void dfs(int x, int p) {
  lvl[x] = lvl[p] + 1;
  sprs[x][0] = p;
  for (int i = 1; i < 30; i++) {
    sprs[x][i] = sprs[sprs[x][i - 1]][i - 1];
  }
  for (int i = 0; i < v[x].size(); i++) {
    int a = v[x][i].first;
    if (a != p) {
      par[a] = make_pair(x, v[x][i].second);
      dfs(a, x);
    }
  }
}
int lca(int x, int y) {
  if (lvl[x] < lvl[y]) swap(x, y);
  for (int i = 29; i >= 0; i--) {
    if (lvl[y] <= lvl[sprs[x][i]]) x = sprs[x][i];
  }
  if (x == y) return x;
  for (int i = 29; i >= 0; i--) {
    if (sprs[x][i] != sprs[y][i]) {
      x = sprs[x][i];
      y = sprs[y][i];
    }
  }
  return sprs[x][0];
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(make_pair(b, i));
    v[b].push_back(make_pair(a, i));
  }
  dfs(1, 0);
  cin >> k;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    pfx[a]++;
    pfx[b]++;
    pfx[lca(a, b)] -= 2;
  }
  for (int i = 1; i <= n; i++) cur[i] = v[i].size() - 1;
  queue<pair<int, int> > q;
  for (int i = 2; i <= n; i++) {
    if (!cur[i]) q.push(make_pair(i, pfx[i]));
  }
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    ans[par[p.first].second] = p.second;
    for (int i = 0; i < v[p.first].size(); i++) {
      int a = v[p.first][i].first;
      cur[a]--;
      pfx[a] += p.second;
      if (!cur[a] && a != 1) q.push(make_pair(a, pfx[a]));
    }
  }
  for (int i = 0; i < n - 1; i++) cout << ans[i] << " ";
  return 0;
}
