#include <bits/stdc++.h>
using namespace std;
void getTree(const int n, int ary[], int height[], int edgeno[], int sqa[]) {
  list<pair<int, int> > adj[n];
  for (int i = 1; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    adj[a].push_back(make_pair(b, i));
    adj[b].push_back(make_pair(a, i));
  }
  fill(ary, ary + n, -1);
  stack<int> s;
  s.push(0);
  ary[0] = 0;
  height[0] = 0;
  edgeno[0] = 0;
  while (!s.empty()) {
    int x = s.top();
    s.pop();
    for (list<pair<int, int> >::iterator it = adj[x].begin();
         it != adj[x].end(); ++it)
      if (ary[it->first] < 0) {
        s.push(it->first);
        ary[it->first] = x;
        height[it->first] = height[x] + 1;
        edgeno[it->first] = it->second;
      }
  }
  fill(sqa, sqa + n, -1);
  int nr = sqrt(*max_element(height, height + n));
  s.push(0);
  while (!s.empty()) {
    int i = s.top();
    s.pop();
    if (height[i] < nr)
      sqa[i] = 0;
    else if (!(height[i] % nr))
      sqa[i] = ary[i];
    else
      sqa[i] = sqa[ary[i]];
    for (list<pair<int, int> >::iterator it = adj[i].begin();
         it != adj[i].end(); ++it)
      if (sqa[it->first] < 0) {
        s.push(it->first);
      }
  }
}
int lca(int p[], int h[], int sqla[], int a, int b) {
  while (sqla[a] != sqla[b])
    if (h[a] < h[b])
      b = sqla[b];
    else
      a = sqla[a];
  while (a != b) {
    if (h[a] < h[b])
      b = p[b];
    else
      a = p[a];
  }
  return a;
}
int main() {
  int n;
  scanf("%d", &n);
  int parent[n], height[n], edgeno[n], sqa[n];
  getTree(n, parent, height, edgeno, sqa);
  int k;
  scanf("%d", &k);
  int times[n];
  fill(times, times + n, 0);
  while (k--) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    times[a]++;
    times[b]++;
    times[lca(parent, height, sqa, a, b)] -= 2;
  }
  int ans[n];
  priority_queue<pair<int, int> > q;
  for (int i = 0; i < n; ++i) q.push(make_pair(height[i], i));
  while (!q.empty()) {
    int x = q.top().second;
    q.pop();
    ans[edgeno[x]] = times[x];
    times[parent[x]] += times[x];
  }
  for (int i = 1; i < n; ++i) printf("%d ", ans[i]);
  puts("");
  return 0;
}
