#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<pair<int, int> > E[N];
int n, k, h[N], anc[N][30], logN, id[N], f[N], ans[N], res[N];
void DFS(int u) {
  for (int i = 0; i < int(E[u].size()); ++i) {
    int v = E[u][i].first;
    if (!h[v]) {
      h[v] = h[u] + 1;
      anc[v][0] = u;
      DFS(v);
    }
  }
}
void InitLCA() {
  logN = 0;
  while (1 << (logN + 1) <= N) ++logN;
  for (int i = 1; i <= logN; ++i)
    for (int u = 1; u <= n; ++u) anc[u][i] = anc[anc[u][i - 1]][i - 1];
}
int LCA(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  for (int i = logN; i >= 0; --i)
    if (h[u] - (1 << i) >= h[v]) u = anc[u][i];
  if (u == v) return u;
  for (int i = logN; i >= 0; --i)
    if (anc[u][i] != anc[v][i]) {
      u = anc[u][i];
      v = anc[v][i];
    }
  return anc[u][0];
}
bool cmp(int x, int y) { return h[x] > h[y]; }
void Query(int u) {
  for (int i = 0; i < int(E[u].size()); ++i) {
    int v = E[u][i].first;
    if (h[v] < h[u]) {
      f[v] += f[u];
      ans[u] = E[u][i].second;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0, _n = n - 1; i < _n; ++i) {
    int u, v;
    cin >> u >> v;
    E[u].push_back(make_pair(v, i + 1));
    E[v].push_back(make_pair(u, i + 1));
  }
  h[1] = 1;
  DFS(1);
  InitLCA();
  cin >> k;
  for (int i = 0, _n = k; i < _n; ++i) {
    int a, b;
    cin >> a >> b;
    ++f[a], ++f[b];
    int u = LCA(a, b);
    f[u] -= 2;
  }
  for (int i = 1; i <= n; ++i) id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  for (int i = 1; i <= n; ++i) Query(id[i]);
  for (int i = 2; i <= n; ++i) res[ans[i]] = f[i];
  for (int i = 1; i <= n - 1; ++i) cout << res[i] << " ";
}
