#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int N;
vector<int> adj[MAXN], eid[MAXN];
int dp[MAXN][20];
int depth[MAXN];
int cnt[MAXN];
int par[MAXN];
int pid[MAXN];
int ans[MAXN];
void dfs(int n, int p, int d) {
  par[n] = p;
  depth[n] = d;
  for (int i = 0, _i = adj[n].size(); i < _i; ++i) {
    if (adj[n][i] != p)
      dfs(adj[n][i], n, d + 1);
    else {
      pid[n] = eid[n][i];
    }
  }
}
void initlca() {
  for (int i = 0; i <= N; i++) {
    for (int j = 0; (1 << j) <= N; j++) {
      dp[i][j] = -1;
    }
  }
  for (int i = 1; i <= N; i++) {
    dp[i][0] = par[i];
  }
  for (int j = 1; (1 << j) <= N; j++) {
    for (int i = 1; i <= N; i++) {
      if (dp[i][j - 1] != -1) {
        dp[i][j] = dp[dp[i][j - 1]][j - 1];
      }
    }
  }
}
int lca(int p, int q) {
  if (depth[q] > depth[p]) swap(p, q);
  int lg = 1;
  for (lg = 1; (1 << lg) <= depth[p]; lg++) {
  }
  lg--;
  for (int i = lg; i >= 0; i--) {
    if (depth[p] - (1 << i) >= depth[q]) p = dp[p][i];
  }
  if (p == q) return p;
  for (int i = lg; i >= 0; i--) {
    if (dp[p][i] != -1 && dp[p][i] != dp[q][i]) {
      p = dp[p][i];
      q = dp[q][i];
    }
  }
  return par[p];
}
int go(int n, int p) {
  int ret = cnt[n];
  for (int i = 0, _i = adj[n].size(); i < _i; ++i) {
    if (adj[n][i] != p) {
      ret += go(adj[n][i], n);
    }
  }
  if (p != -1) {
    ans[pid[n]] = ret;
  }
  return ret;
}
int main(int argc, char *argv[]) {
  scanf("%d", &N);
  for (int i = 0, _i = N - 1; i < _i; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
    eid[a].push_back(i);
    eid[b].push_back(i);
  }
  dfs(1, -1, 0);
  initlca();
  int k;
  scanf("%d", &k);
  for (int i = 0, _i = k; i < _i; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    int c = lca(a, b);
    cnt[a]++;
    cnt[b]++;
    cnt[c] -= 2;
  }
  go(1, -1);
  for (int i = 0, _i = N - 1; i < _i; ++i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
