#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
struct ST {
  int st[4 * MAX], lazy[4 * MAX];
  void push(int p, int l, int r) {
    if (lazy[p]) {
      st[l] += lazy[p];
      st[r] += lazy[p];
      lazy[l] += lazy[p];
      lazy[r] += lazy[p];
      lazy[p] = 0;
    }
  }
  void update(int p, int b, int e, int x, int y, int v) {
    if (x <= b && e <= y) {
      st[p] += v;
      lazy[p] += v;
    } else {
      int m = (b + e) >> 1, l = 2 * p, r = 2 * p + 1;
      push(p, l, r);
      if (x < m) update(l, b, m, x, y, v);
      if (m < y) update(r, m, e, x, y, v);
      st[p] = st[l] + st[r];
    }
  }
  int query(int p, int b, int e, int pos) {
    if (b + 1 == e) return st[p];
    int m = (b + e) >> 1, l = 2 * p, r = 2 * p + 1;
    push(p, l, r);
    if (pos < m) return query(l, b, m, pos);
    return query(r, m, e, pos);
  }
};
struct heavy_light {
  int n, root[MAX], depth[MAX], heavy[MAX];
  int parent[MAX], pos[MAX], ipos[MAX];
  int dfs(int s, int p, vector<vector<int> > &g) {
    parent[s] = p, heavy[s] = -1;
    int size = 1, maxsubtree = 0;
    for (auto u : g[s]) {
      if (u == p) continue;
      depth[u] = depth[s] + 1;
      int subtree = dfs(u, s, g);
      if (subtree > maxsubtree) heavy[s] = u, maxsubtree = subtree;
      size += subtree;
    }
    return size;
  }
  void go(vector<vector<int> > &g, int ROOT = 0) {
    n = g.size();
    depth[ROOT] = 0;
    dfs(ROOT, -1, g);
    for (int i = 0, curpos = 0; i < n; ++i)
      if (parent[i] == -1 || heavy[parent[i]] != i)
        for (int u = i; u != -1; u = heavy[u], curpos++)
          root[u] = i, pos[u] = curpos, ipos[curpos] = u;
  }
  void lca(int u, int v, ST &st) {
    for (; root[u] != root[v]; v = parent[root[v]]) {
      if (depth[root[u]] > depth[root[v]]) swap(u, v);
      st.update(1, 0, n, pos[root[v]], pos[v] + 1, 1);
    }
    if (depth[u] > depth[v]) swap(u, v);
    if (u != v) st.update(1, 0, n, pos[u] + 1, pos[v] + 1, 1);
  }
  int query(int u, int v, ST &st) {
    if (v == parent[u]) swap(u, v);
    return st.query(1, 0, n, pos[v]);
  }
};
ST st;
heavy_light hld;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int> > g(n);
  vector<pair<int, int> > edges;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
    edges.push_back({a, b});
  }
  hld.go(g);
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    hld.lca(a, b, st);
  }
  for (int i = 0; i < (int)edges.size(); ++i) {
    cout << hld.query(edges[i].first, edges[i].second, st) << " ";
  }
  cout << '\n';
  return 0;
}
