#include <bits/stdc++.h>
using namespace std;
struct Node {
  int level;
  int cnt;
  vector<int> p2;
  vector<int> next;
  Node() {
    level = 0;
    cnt = 0;
    p2 = vector<int>();
    next = vector<int>();
  }
  void AddNext(const int& x) { next.push_back(x); }
};
void BuildLca(int i, int prev, vector<Node*>& v, vector<int>& way) {
  v[i]->level = way.size();
  for (int j = way.size() - 1, q = 1; j >= 0; j -= q, q *= 2) {
    v[i]->p2.push_back(way[j]);
  }
  way.push_back(i);
  for (auto j : v[i]->next) {
    if (j != prev) {
      BuildLca(j, i, v, way);
    }
  }
  way.pop_back();
}
int GetLca(int a, int b, vector<Node*>& v) {
  if (v[a]->level < v[b]->level) {
    swap(a, b);
  }
  int diff = v[a]->level - v[b]->level;
  int lvl = 0;
  while (diff != 0) {
    if (diff ^ ((diff >> 1) << 1)) {
      a = v[a]->p2[lvl];
    }
    diff = (diff >> 1);
    lvl++;
  }
  while (a != b) {
    int ans = 0;
    for (int i = 1; i < v[a]->p2.size(); i++) {
      if (v[a]->p2[i] != v[b]->p2[i]) ans = i;
    }
    a = v[a]->p2[ans];
    b = v[b]->p2[ans];
  }
  return a;
}
int dfs(int i, int prev, vector<Node*>& v, map<pair<int, int>, int>& mp) {
  for (auto j : v[i]->next) {
    if (j != prev) {
      v[i]->cnt += dfs(j, i, v, mp);
    }
  }
  if (prev != -1) {
    mp[{min(i, prev), max(i, prev)}] = v[i]->cnt;
  }
  return v[i]->cnt;
}
int main() {
  int n;
  cin >> n;
  vector<Node*> v(n);
  for (int i = 0; i < n; i++) v[i] = new Node();
  vector<int> way;
  map<pair<int, int>, int> mp;
  vector<pair<int, int> > edges;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges.push_back(make_pair(min(a, b), max(a, b)));
    v[a]->AddNext(b);
    v[b]->AddNext(a);
  }
  BuildLca(0, -1, v, way);
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a]->cnt++;
    v[b]->cnt++;
    v[GetLca(a, b, v)]->cnt -= 2;
  }
  dfs(0, -1, v, mp);
  for (auto i : edges) {
    cout << mp[i] << " ";
  }
}
