#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000007;
vector<vector<int> > g;
vector<int> ord;
int fin[1001000], key[1000110], unkey[1000110], used[1000100], tree[4001000],
    r[1010000], ans[1000100];
int timer = 0;
map<pair<int, int>, int> numb;
void dfs(int v) {
  used[v] = 1;
  key[v] = timer++;
  unkey[key[v]] = v;
  if (fin[v] == -1) fin[v] = ord.size();
  ord.push_back(key[v]);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (used[to]) continue;
    dfs(to);
    ord.push_back(key[v]);
  }
  return;
}
void inc(int v, int l, int r, int k) {
  if (l + 1 == r) {
    tree[v] = ord[k];
    return;
  }
  int m = (l + r) / 2;
  if (k < m)
    inc(2 * v + 1, l, m, k);
  else if (k >= m)
    inc(2 * v + 2, m, r, k);
  tree[v] = min(tree[2 * v + 1], tree[2 * v + 2]);
  return;
}
int findmin(int v, int l, int r, int lv, int rv) {
  if (l == lv && r == rv) return tree[v];
  int m = (l + r) / 2;
  if (m >= rv)
    return findmin(2 * v + 1, l, m, lv, rv);
  else if (m <= lv)
    return findmin(2 * v + 2, m, r, lv, rv);
  return min(findmin(2 * v + 1, l, m, lv, m), findmin(2 * v + 2, m, r, m, rv));
}
int dfs0(int v) {
  int w = r[v];
  used[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (used[to]) continue;
    int d = dfs0(to);
    ans[numb[make_pair(min(v, to), max(v, to))]] = d;
    w += d;
  }
  return w;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, u, v;
  cin >> n;
  g.resize(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> v >> u;
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
    numb.insert(make_pair(make_pair(min(v, u), max(v, u)), i));
  }
  fill(fin, fin + n, -1);
  fill(used, used + n, 0);
  fill(tree, tree + 4 * n + 4, inf);
  fill(r, r + n, 0);
  dfs(0);
  for (int i = 0; i < ord.size(); i++) inc(0, 0, ord.size(), i);
  int m;
  cin >> m;
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    if (fin[x] > fin[y]) swap(x, y);
    int lca = unkey[findmin(0, 0, ord.size(), fin[x], fin[y] + 1)];
    r[x]++;
    r[y]++;
    r[lca] -= 2;
  }
  fill(used, used + n, 0);
  int t = dfs0(0);
  for (int i = 0; i < n - 1; i++) cout << ans[i] << " ";
  return 0;
}
