#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e6;
vector<vector<int> > g;
vector<int> d;
vector<int> fin;
vector<int> lst;
vector<int> to, back;
int timer = 0;
void dfs(int v, int p = -1) {
  if (to[v] == -1) {
    to[v] = timer;
    back[timer] = v;
    timer++;
  }
  if (fin[v] == -1) fin[v] = lst.size();
  lst.push_back(to[v]);
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i] == p) continue;
    dfs(g[v][i], v);
    lst.push_back(to[v]);
  }
}
vector<int> ans;
int dfs1(int v, int p = -1) {
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i] == p) continue;
    ans[v] += dfs1(g[v][i], v);
  }
  ans[v] += d[v];
  return ans[v];
}
vector<int> tree(4 * INF);
void inc(int vertex, int left, int right, int i, int value) {
  if (left == right - 1) {
    tree[vertex] = value;
    return;
  }
  int m = (left + right) / 2;
  if (i < m) {
    inc(2 * vertex + 1, left, m, i, value);
  } else
    inc(2 * vertex + 2, m, right, i, value);
  tree[vertex] = min(tree[2 * vertex + 1], tree[2 * vertex + 2]);
}
int query(int vertex, int left, int right, int i, int j) {
  if (i == left && j == right) {
    return tree[vertex];
  }
  int m = (left + right) / 2;
  if (j <= m) return query(2 * vertex + 1, left, m, i, j);
  if (i >= m) return query(2 * vertex + 2, m, right, i, j);
  return min(query(2 * vertex + 1, left, m, i, m),
             query(2 * vertex + 2, m, right, m, j));
}
int lca(int a, int b) {
  if (a > b) swap(a, b);
  return query(0, 0, lst.size(), a, b + 1);
}
int main() {
  int n;
  cin >> n;
  g.resize(n);
  d.resize(n);
  fin.assign(n, -1);
  to.assign(n, -1);
  back.assign(n, -1);
  vector<pair<int, int> > road;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
    road.push_back(make_pair(a, b));
  }
  dfs(0);
  for (int i = 0; i < lst.size(); i++) inc(0, 0, lst.size(), i, lst[i]);
  int m;
  cin >> m;
  d.assign(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int c = back[lca(fin[a], fin[b])];
    d[a]++;
    d[b]++;
    d[c] -= 2;
  }
  ans.assign(n, 0);
  dfs1(0);
  for (int i = 0; i < road.size(); i++) {
    if (fin[road[i].first] > fin[road[i].second])
      cout << ans[road[i].first] << " ";
    else
      cout << ans[road[i].second] << " ";
  }
  return 0;
}
