#include <bits/stdc++.h>
using namespace std;
int t;
int p[100001][21], volum[100001], vv[100001], cnt[100001], n, ans = 0;
pair<int, int> a[100001];
vector<int> g[100001];
void DFS(int v, int pa) {
  p[v][0] = pa;
  for (int i = 0; i < g[v].size(); i++) {
    int k = g[v][i];
    if (k != pa) {
      volum[k] = volum[v] + 1;
      DFS(k, v);
    }
  }
}
int kanst(int v, int k) {
  while (k > 0) {
    int k1 = log2(k);
    v = p[v][k1];
    k -= (1 << k1);
  }
  return v;
}
void prapare() {
  for (int i = 0; i <= n; i++)
    for (int j = 1; j <= 18; j++) {
      p[i][j] = -1;
    }
  DFS(1, -1);
  for (int j = 1; j <= 18; j++)
    for (int i = 1; i <= n; i++) {
      if (p[i][j - 1] != -1) p[i][j] = p[p[i][j - 1]][j - 1];
    }
}
int LCA(int a, int b) {
  if (a == b) return a;
  if (volum[b] > volum[a]) swap(a, b);
  if (volum[a] != volum[b]) a = kanst(a, volum[a] - volum[b]);
  if (a == b) return a;
  for (int j = 18; j >= 0; j--) {
    if (p[a][j] != p[b][j]) {
      a = p[a][j];
      b = p[b][j];
    }
  }
  return p[a][0];
}
void DFS1(int v, int pa) {
  int t = 0;
  for (int x = 0; x < g[v].size(); x++)
    if (g[v][x] != pa) {
      DFS1(g[v][x], v);
      t += cnt[g[v][x]];
    }
  if (v != 1 && g[v].size() == 1)
    cnt[v] = vv[v];
  else
    cnt[v] = vv[v] + t;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int m;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    g[a[i].first].push_back(a[i].second);
    g[a[i].second].push_back(a[i].first);
  }
  prapare();
  cin >> m;
  for (int i = 1, x, y; i <= m; i++) {
    cin >> x >> y;
    vv[x]++;
    vv[y]++;
    vv[LCA(x, y)] -= 2;
  }
  DFS1(1, -1);
  for (int i = 1; i < n; i++) {
    ans = 0;
    if (volum[a[i].second] > volum[a[i].first])
      cout << cnt[a[i].second] << ' ';
    else
      cout << cnt[a[i].first] << ' ';
  }
}
