#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
vector<pair<int, int> > adj[MAX];
int par[MAX][25], d[MAX], ans[MAX], c[MAX];
multiset<int> s, a;
bool mark[MAX];
int cnt, n, k;
void dfs(int v) {
  mark[v] = true;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i].first;
    if (mark[u]) continue;
    par[u][0] = v;
    d[u] = d[v] + 1;
    dfs(u);
  }
}
void init() {
  dfs(1);
  for (int h = 0; h < 25; h++) par[1][h] = -1;
  for (int h = 1; h < 25; h++)
    for (int v = 2; v <= n; v++) par[v][h] = par[par[v][h - 1]][h - 1];
}
int lca(int u, int v) {
  if (d[v] > d[u]) swap(u, v);
  int log = 0;
  for (; (1 << log) <= d[u]; log++)
    ;
  log--;
  for (int i = log; i >= 0; i--)
    if (d[u] - (1 << i) >= d[v]) u = par[u][i];
  if (u == v) return u;
  for (int i = log; i >= 0; i--)
    if (par[u][i] != -1 && par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  return par[u][0];
}
int solve(int v) {
  mark[v] = true;
  int sum = 0;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i].first;
    if (mark[u]) continue;
    int index = adj[v][i].second;
    int val = solve(u) + c[u];
    sum += val;
    ans[index] = val;
  }
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(make_pair(v, i));
    adj[v].push_back(make_pair(u, i));
  }
  init();
  cin >> k;
  for (int i = 0; i < k; i++) {
    int first, last;
    cin >> first >> last;
    c[first]++;
    c[last]++;
    c[lca(first, last)] -= 2;
  }
  memset(mark, false, sizeof(mark));
  solve(1);
  for (int i = 0; i < n - 1; i++) cout << ans[i] << " ";
  return 0;
}
