#include <bits/stdc++.h>
using namespace std;
const int MAXK = 100099;
const int MAXN = 100099;
const int MAXM = 809;
const long double eps = 1e-9;
const long double Log2 = logl(2);
const long double Log3 = logl(3);
int n;
int k;
int cnt[MAXN];
vector<vector<pair<int, int> > > G;
vector<vector<int> > add;
struct sizeComp {
  bool operator()(const unordered_set<int> a,
                  const unordered_set<int> b) const {
    return a.size() < b.size();
  }
};
struct sizeComp1 {
  bool operator()(const unordered_set<int>* a,
                  const unordered_set<int>* b) const {
    return a->size() < b->size();
  }
};
unordered_set<int>* dfs(int v, int p) {
  vector<unordered_set<int>*> chld;
  for (int i = 0, _n = (G[v].size()); i < _n; i++) {
    int to = G[v][i].first;
    if (to == p) continue;
    int id = G[v][i].second;
    chld.push_back(dfs(to, v));
    cnt[id] += chld.back()->size();
  }
  sort(chld.begin(), chld.end(), sizeComp1());
  unordered_set<int>* result;
  if (chld.size() > 0) {
    result = chld.back();
  } else {
    result = new unordered_set<int>();
  }
  for (int i = 0, _n = (add[v].size()); i < _n; i++) {
    auto it = result->find(add[v][i]);
    if (it != result->end()) {
      result->erase(it);
    } else {
      result->insert(add[v][i]);
    }
  }
  for (int i = 0, _n = (chld.size() - 1); i < _n; i++) {
    for (auto first : *chld[i]) {
      auto it = result->find(first);
      if (it != result->end()) {
        result->erase(it);
      } else {
        result->insert(first);
      }
    }
    chld[i]->clear();
  }
  return result;
}
int main() {
  double t1 = clock();
  scanf("%d", &n);
  add.resize(n);
  G.resize(n);
  for (int i = 0, _n = (n - 1); i < _n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    G[u].push_back(make_pair(v, i));
    G[v].push_back(make_pair(u, i));
  }
  scanf("%d", &k);
  for (int i = 0, _n = (k); i < _n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    add[a].push_back(i);
    add[b].push_back(i);
  }
  dfs(0, -1);
  for (int i = 0, _n = (n - 1); i < _n; i++) {
    if (i) printf(" ");
    printf("%d", cnt[i]);
  }
  printf("\n");
  double t2 = clock();
  return 0;
}
