#include <bits/stdc++.h>
using namespace std;
const int MX = 3 * 1e5 + 10;
const double PI = acos(-1.0), EPS = 1e-9;
int N, M;
vector<vector<int> > G(MX);
int dp[22][MX];
int dep[MX], fr[MX], to[MX], lazy[MX], on_node[MX];
void calc(int x, int p) {
  dp[0][x] = p;
  for (int i = 0; i < (int)G[x].size(); i++) {
    int ch = G[x][i];
    if (ch == p) continue;
    dep[ch] = dep[x] + 1;
    calc(ch, x);
  }
}
int Jump(int u, int v) {
  if (dep[u] >= dep[v]) swap(u, v);
  int d = dep[v] - dep[u];
  for (int i = 0; i <= 20; i++)
    if (d & (1 << i)) v = dp[i][v];
  if (u == v) return u;
  for (int i = 20; i >= 0; i--) {
    if (dp[i][u] != dp[i][v]) {
      u = dp[i][u];
      v = dp[i][v];
    }
  }
  return dp[0][u];
}
void dfs_lazy(int x, int p) {
  for (int i = 0; i < G[x].size(); i++) {
    int ch = G[x][i];
    if (ch == p) continue;
    dfs_lazy(ch, x);
    lazy[x] += lazy[ch];
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N - 1; i++) {
    scanf("%d%d", &fr[i], &to[i]);
    G[fr[i]].push_back(to[i]);
    G[to[i]].push_back(fr[i]);
  }
  memset(dp, -1, sizeof dp);
  calc(1, -1);
  for (int j = 1; j <= 20; j++) {
    for (int i = 1; i <= N; i++) {
      if (dp[j - 1][i] != -1) dp[j][i] = dp[j - 1][dp[j - 1][i]];
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    int J = Jump(a, b);
    if (J == a) {
      lazy[b]++;
      lazy[J]--;
    } else if (J == b) {
      lazy[a]++;
      lazy[J]--;
    } else {
      lazy[a]++;
      lazy[b]++;
      lazy[J] -= 2;
    }
  }
  dfs_lazy(1, -1);
  for (int i = 0; i < N - 1; i++) {
    int u = fr[i], v = to[i];
    if (dep[u] > dep[v]) swap(u, v);
    cout << lazy[v] << " ";
  }
  return 0;
}
