#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e5 + 5;
const int MOD = 1e9 + 7;
int n, k;
vector<int> g[MXN];
int ans[MXN], lvl[MXN], parent[MXN];
int G[20][MXN], gold[20][MXN];
map<pair<int, int>, int> nten;
void calc_levels(int u = 1, int pa = -1, int level = 1) {
  lvl[u] = level;
  parent[u] = pa;
  for (int j = 0; j < g[u].size(); j++) {
    int v = g[u][j];
    if (v == pa) continue;
    calc_levels(v, u, level + 1);
  }
}
void preprocess() {
  calc_levels();
  for (int i = 1; i <= n; i++) G[0][i] = parent[i];
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      int middle_parent = G[i - 1][j];
      if (middle_parent <= 0)
        G[i][j] = -1;
      else
        G[i][j] = G[i - 1][middle_parent];
    }
  }
}
int get_lca(int u, int v) {
  if (lvl[u] > lvl[v]) swap(u, v);
  int diff = lvl[v] - lvl[u];
  for (int i = 0; lvl[v] != lvl[u]; i++) {
    if ((diff >> i) & 1) {
      gold[i][v]++;
      v = G[i][v];
    }
  }
  if (u == v) return u;
  for (int i = 19; i >= 0; i--) {
    if (G[i][v] != G[i][u] && G[i][v] != -1) {
      gold[i][u]++;
      gold[i][v]++;
      v = G[i][v];
      u = G[i][u];
    }
  }
  gold[0][u]++;
  gold[0][v]++;
  return parent[v];
}
void push_to_leaves() {
  for (int i = 19; i > 0; i--) {
    for (int j = 1; j <= n; j++) {
      gold[i - 1][j] += gold[i][j];
      if (G[i][j] > 0) gold[i - 1][G[i - 1][j]] += gold[i][j];
    }
  }
}
void calc_answer(int u = 1, int pa = -1) {
  for (int j = 0; j < g[u].size(); j++) {
    int v = g[u][j];
    if (v == pa) continue;
    ans[nten[make_pair(min(u, v), max(u, v))]] = gold[0][v];
    calc_answer(v, u);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int u, v;
  cin >> 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);
    nten[make_pair(min(u, v), max(u, v))] = i;
  }
  preprocess();
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> u >> v;
    int common_ancestor = get_lca(u, v);
  }
  push_to_leaves();
  calc_answer();
  for (int i = 0; i < n - 1; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
