#include <bits/stdc++.h>
using namespace std;
vector<int> g[500001];
vector<int> q[500001];
vector<int> visited;
vector<int> parent;
vector<int> anc;
vector<int> pre;
vector<int> par;
int find(int u) {
  if (parent[u] != u) {
    parent[u] = find(parent[u]);
  }
  return parent[u];
}
void join(int u, int v) {
  int pu = find(u);
  int pv = find(v);
  parent[pu] = pv;
}
void lca(int u) {
  parent[u] = u;
  anc[u] = u;
  visited[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (!visited[v]) {
      lca(v);
      join(u, v);
      anc[find(u)] = u;
    }
  }
  visited[u] = 2;
  int v = u;
  for (int j = 0; j < q[v].size(); j++) {
    if (visited[q[v][j]] == 2) {
      int lca = anc[find(q[v][j])];
      pre[u] += 1;
      pre[q[v][j]] += 1;
      pre[lca] -= 2;
    }
  }
}
void pardfs(int u) {
  visited[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (!visited[v]) {
      par[v] = u;
      pardfs(v);
    }
  }
}
map<pair<int, int>, int> edges;
vector<int> ans;
void prefixDfs(int u) {
  visited[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    int ed = edges[make_pair(min(u, v), max(u, v))];
    if (!visited[v]) {
      prefixDfs(g[u][i]);
      ans[ed] += pre[g[u][i]];
      pre[u] += pre[g[u][i]];
    }
  }
}
int main() {
  int n;
  cin >> n;
  visited.resize(n + 1);
  par.resize(n + 1);
  parent.resize(n + 1);
  pre.resize(n + 1);
  anc.resize(n + 1);
  ans.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    if (u > v) {
      swap(u, v);
    }
    edges[make_pair(u, v)] = i;
  }
  int que;
  cin >> que;
  for (int i = 0; i < que; i++) {
    int u, v;
    cin >> u >> v;
    if (u != v) {
      q[u].push_back(v);
      q[v].push_back(u);
    }
  }
  pardfs(1);
  visited = vector<int>(n + 1);
  lca(1);
  visited = vector<int>(n + 1);
  prefixDfs(1);
  for (int i = 0; i < n - 1; i++) {
    cout << ans[i] << " ";
  }
  cout << '\n';
}
