#include <bits/stdc++.h>
using namespace std;
int n, maxN, q;
std::vector<int> adj[100001];
std::vector<pair<int, int>> edges;
int par[100001], dp[100001][17], depth[100001], cnt[100001];
int LOG_2(int x) {
  int res = 0;
  while (x >>= 1) res++;
  return res;
}
void dfs(int u, int p) {
  dp[u][0] = p;
  par[u] = p;
  for (auto child : adj[u]) {
    if (child != p) {
      depth[child] = depth[u] + 1;
      dfs(child, u);
    }
  }
}
void init() {
  for (int j = 1; j <= maxN; ++j) {
    for (int i = 1; i <= n; ++i) {
      int par = dp[i][j - 1];
      dp[i][j] = dp[par][j - 1];
    }
  }
}
int LCA(int u, int v) {
  if (depth[v] > depth[u]) swap(u, v);
  int d = depth[u] - depth[v];
  int a = u, b = v;
  while (d > 0) {
    int i = LOG_2(d);
    a = dp[a][i];
    d -= (1 << i);
  }
  if (a == b) return a;
  for (int i = maxN; i >= 0; --i) {
    if (dp[a][i] != -1 && dp[a][i] != dp[b][i]) {
      a = dp[a][i];
      b = dp[b][i];
    }
  }
  return dp[a][0];
}
void dfs2(int u, int par) {
  for (auto child : adj[u]) {
    if (child != par) {
      dfs2(child, u);
      cnt[u] += cnt[child];
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  maxN = log2(n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    edges.push_back({u, v});
  }
  for (int j = 0; j <= maxN; ++j) {
    for (int i = 0; i <= n; ++i) {
      dp[i][j] = -1;
    }
  }
  dfs(1, -1);
  init();
  cin >> q;
  while (q--) {
    int u, v;
    cin >> u >> v;
    int lca = LCA(u, v);
    cnt[u]++;
    cnt[v]++;
    cnt[lca] -= 2;
  }
  dfs2(1, -1);
  for (int i = 0; i < edges.size(); ++i) {
    int u = edges[i].first;
    int v = edges[i].second;
    if (par[u] == v)
      cout << cnt[u] << " ";
    else
      cout << cnt[v] << " ";
  }
  cout << "\n";
  return 0;
}
