#include <bits/stdc++.h>
using namespace std;
struct _ {
  ios_base::Init i;
  _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); }
} _;
const int lgn = 32;
int n;
vector<vector<int>> gr;
vector<vector<int>> P;
vector<int> lvl, ans, dp;
map<pair<int, int>, int> ind;
void pre(int curr, int par) {
  lvl[curr] = lvl[par] + 1;
  P[curr][0] = par;
  for (int j = 1; j <= lgn; j++) P[curr][j] = P[P[curr][j - 1]][j - 1];
  for (auto child : gr[curr]) {
    if (child == par) continue;
    pre(child, curr);
  }
  return;
}
int lca(int u, int v) {
  if (lvl[u] > lvl[v]) swap(u, v);
  for (int j = lgn; j >= 0; j--) {
    if (lvl[P[v][j]] >= lvl[u]) v = P[v][j];
  }
  if (u == v) return u;
  for (int j = lgn; j >= 0; j--) {
    if (P[u][j] != P[v][j]) u = P[u][j], v = P[v][j];
  }
  return P[u][0];
}
void pull(int curr, int par) {
  for (auto child : gr[curr]) {
    if (child == par) continue;
    pull(child, curr);
    dp[curr] += dp[child];
  }
  if (curr != 1) ans[ind[{curr, par}]] = dp[curr];
  return;
}
int main() {
  cin >> n;
  gr.resize(n + 1);
  lvl.resize(n + 1, 0);
  dp.resize(n + 1, 0);
  ans.resize(n - 1, 0);
  P.resize(n + 1, vector<int>(lgn + 1, 0));
  for (int i = 0; i <= n - 2; i++) {
    int u, v;
    cin >> u >> v;
    gr[u].push_back(v);
    gr[v].push_back(u);
    ind[{u, v}] = ind[{v, u}] = i;
  }
  pre(1, 1);
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (lvl[a] > lvl[b]) swap(a, b);
    int lc = lca(a, b);
    if (lc == a) {
      dp[b]++;
      dp[a]--;
    } else {
      dp[a]++;
      dp[b]++;
      dp[lc] -= 2;
    }
  }
  pull(1, 1);
  for (int i = 0; i <= n - 2; i++) cout << ans[i] << " ";
  return 0;
}
