#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, inf = 1e16, lim = 1e5 + 10;
const double eps = 1e-15;
template <typename T = int>
inline void in(T& p) {
  p = 0;
  register bool negative = false;
  register char ch = 0;
  while (ch < 0x30 or ch > 0x39) {
    if (ch == '-') negative = true;
    ch = getchar();
  }
  while (ch >= 0x30 and ch <= 0x39) {
    p = (p << 1) + (p << 3) + (ch & 15);
    ch = getchar();
  }
  if (negative) p = -p;
}
map<pair<int, int>, int> ed;
vector<int> t[lim];
int lca[25][lim], h[lim], val[lim], ans[lim];
void bfs(int v, int p) {
  lca[0][v] = p;
  for (long long i = 1, _b = (20); i <= _b; i++)
    lca[i][v] = lca[i - 1][lca[i - 1][v]];
  for (int ch : t[v])
    if (ch != p) h[ch] = h[v] + 1, bfs(ch, v);
}
void push(int v, int p) {
  for (int ch : t[v])
    if (ch != p) push(ch, v), val[v] += val[ch];
  ans[ed[make_pair(v, p)]] = val[v];
}
inline int find_lca(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  int x = h[u] - h[v];
  if (x)
    for (long long i = 0, _n = (20); i < _n; i++)
      if (x >> i & 1) u = lca[i][u];
  if (u == v) return u;
  for (long long i = 18, _a = (0); i >= _a; i--)
    if (lca[i][u] != lca[i][v]) u = lca[i][u], v = lca[i][v];
  return lca[0][u];
}
int main() {
  int x, y, z;
  int n;
  cin >> n;
  for (long long i = 0, _n = (n - 1); i < _n; i++) {
    in(x), in(y);
    t[x].emplace_back(y), t[y].emplace_back(x);
    ed[make_pair(x, y)] = i + 1;
    ed[make_pair(y, x)] = i + 1;
  }
  bfs(1, 1);
  int k;
  cin >> k;
  for (long long i = 0, _n = (k); i < _n; i++) {
    in(x), in(y);
    z = find_lca(x, y);
    val[x]++, val[y]++, val[z] -= 2;
  }
  push(1, 1);
  for (long long i = 1, _b = (n - 1); i <= _b; i++) cout << ans[i] << ' ';
  return 0;
}
