#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<int> start, finish;
vector<int> tin, tout;
vector<int> sum_st, sum_fi;
vector<int> par;
vector<vector<int>> par_2;
int timer = 0;
void go(int v, int fr) {
  tin[v] = timer++;
  par[v] = par_2[v][0] = fr;
  for (int i = 1; i <= 20; ++i) {
    int anc = par_2[v][i - 1];
    if (anc == -1)
      par_2[v][i] = -1;
    else
      par_2[v][i] = par_2[anc][i - 1];
  }
  for (int to : g[v]) {
    if (to != fr) {
      go(to, v);
    }
  }
  tout[v] = timer++;
}
void calc(int v, int fr) {
  sum_st[v] = start[v];
  sum_fi[v] = finish[v];
  for (int to : g[v]) {
    if (to != fr) {
      calc(to, v);
      sum_st[v] += sum_st[to];
      sum_fi[v] += sum_fi[to];
    }
  }
}
bool isAncestor(int par, int ch) {
  if (par == -1) return true;
  return tin[par] <= tin[ch] && tout[ch] <= tout[par];
}
int lca(int u, int v) {
  if (isAncestor(u, v)) return u;
  if (isAncestor(v, u)) return v;
  int crr = u;
  for (int i = 20; i >= 0; --i) {
    if (!isAncestor(par_2[crr][i], v)) {
      crr = par_2[crr][i];
    }
  }
  return par[crr];
}
int main() {
  int n;
  cin >> n;
  g.resize(n);
  start.resize(n);
  finish.resize(n);
  tin.resize(n);
  tout.resize(n);
  par.resize(n, -1);
  par_2.resize(n, vector<int>(21));
  int u, v;
  vector<pair<int, int>> ed(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d%d", &u, &v);
    u--;
    v--;
    ed[i] = {u, v};
    g[u].push_back(v);
    g[v].push_back(u);
  }
  go(0, -1);
  int prs;
  cin >> prs;
  for (int i = 0; i < prs; ++i) {
    scanf("%d%d", &u, &v);
    u--;
    v--;
    int LCA = lca(u, v);
    if (u == LCA) {
      start[v]++;
      finish[LCA]++;
    } else if (v == LCA) {
      start[u]++;
      finish[LCA]++;
    } else {
      start[u]++;
      start[v]++;
      finish[LCA] += 2;
    }
  }
  sum_st.resize(n);
  sum_fi.resize(n);
  calc(0, -1);
  for (auto i : ed) {
    int u = i.first, v = i.second;
    if (tin[i.first] > tin[i.second]) swap(u, v);
    printf("%d ", sum_st[v] - sum_fi[v]);
  }
  return 0;
}
