#include <bits/stdc++.h>
const int MAXN = 100005;
using namespace std;
vector<vector<int> > tree(MAXN), dp(MAXN);
int t_in[MAXN], t_out[MAXN], parent[MAXN];
long long d[MAXN];
int n, lg, timer, m;
vector<pair<int, int> > seq;
bool issubtree(int a, int b) {
  return (t_in[a] <= t_in[b] && t_out[b] <= t_out[a]);
}
void DFS(int, int);
int LCA(int, int);
void fDFS(int);
int main() {
  scanf("%d", &n);
  for (int k = 1; k < n; k++) {
    int a, b;
    scanf("%d%d", &a, &b);
    tree[a].push_back(b);
    tree[b].push_back(a);
    seq.push_back({a, b});
  }
  lg = log2(n + 1);
  for (int k = 0; k <= n; k++) dp[k].resize(21);
  scanf("%d", &m);
  DFS(1, 0);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    int lca = LCA(u, v);
    d[u]++;
    d[v]++;
    d[lca] -= 2;
  }
  fDFS(1);
  for (int k = 0; k < seq.size(); k++) {
    int a = seq[k].first;
    int b = seq[k].second;
    if (a == parent[b]) {
      cout << d[b] << ' ';
    } else {
      cout << d[a] << ' ';
    }
  }
  return 0;
}
void DFS(int v, int p) {
  parent[v] = p;
  t_in[v] = timer++;
  dp[v][0] = p;
  for (int k = 1; k <= lg; k++) dp[v][k] = dp[dp[v][k - 1]][k - 1];
  for (int k = 0; k < tree[v].size(); k++) {
    int to = tree[v][k];
    if (to == p) continue;
    DFS(to, v);
  }
  t_out[v] = timer++;
}
int LCA(int a, int b) {
  if (issubtree(a, b)) return a;
  if (issubtree(b, a)) return b;
  for (int k = lg; k >= 0; k--) {
    if (dp[a][k] == 0) continue;
    if (issubtree(dp[a][k], b)) continue;
    a = dp[a][k];
  }
  return parent[a];
}
void fDFS(int v) {
  for (int k = 0; k < tree[v].size(); k++) {
    int to = tree[v][k];
    if (to == parent[v]) continue;
    fDFS(to);
    d[v] += d[to];
  }
}
