#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 7;
int p[maxn][20], h[maxn], dp[maxn], arr[maxn];
vector<int> v[maxn], he[maxn];
inline void dfs(int x) {
  h[x] = h[p[x][0]] + 1;
  he[h[x]].push_back(x);
  for (int i = 1; i < 20; i++) p[x][i] = p[p[x][i - 1]][i - 1];
  for (int i = 0; i < v[x].size(); i++)
    if (v[x][i] != p[x][0]) {
      p[v[x][i]][0] = x;
      dfs(v[x][i]);
    }
}
inline int PAR(int x, int k) {
  for (int i = 20; i >= 0; i--)
    if (k & (1 << i)) x = p[x][i];
  return x;
}
inline int LCA(int x, int y) {
  if (h[x] > h[y]) return LCA(y, x);
  if (h[x] < h[y]) y = PAR(y, h[y] - h[x]);
  if (x == y) return x;
  for (int i = 19; i >= 0; i--)
    if (p[x][i] != p[y][i]) {
      x = p[x][i];
      y = p[y][i];
    }
  return p[x][0];
}
inline void DFS(int x) {
  for (int i = 0; i < he[x].size(); i++) {
    for (int j = 0; j < v[he[x][i]].size(); j++)
      if (v[he[x][i]][j] != p[he[x][i]][0]) dp[he[x][i]] += dp[v[he[x][i]][j]];
    dp[he[x][i]] += arr[he[x][i]];
  }
}
vector<pair<int, int> > t;
int main() {
  int n, x, y, m;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    t.push_back(make_pair(x, y));
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1);
  cin >> m;
  while (m--) {
    cin >> x >> y;
    n = LCA(x, y);
    if (h[x] < h[y]) swap(x, y);
    if (n == y) {
      arr[x]++;
      arr[y]--;
    } else {
      arr[x]++;
      arr[y]++;
      arr[n] -= 2;
    }
  }
  for (int i = t.size() + 1; i >= 0; i--)
    if (he[i].size()) DFS(i);
  for (int i = 0; i < t.size(); i++) {
    if (h[t[i].first] > h[t[i].second])
      printf("%d ", dp[t[i].first]);
    else
      printf("%d ", dp[t[i].second]);
  }
}
