#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > edges[100005];
vector<pair<int, int> > edges2;
int height[100005];
int logtable[100005];
int dp[100005][18];
int values[100005];
int parent[100005];
bool comp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
void dfs(int v, int p, int h) {
  parent[v] = p;
  height[v] = h;
  int i = 0, anc = 1;
  while (anc <= h) {
    if (i == 0)
      dp[v][i] = p;
    else
      dp[v][i] = dp[dp[v][i - 1]][i - 1];
    i++;
    anc *= 2;
  }
  for (int i = 0; i < edges[v].size(); i++) {
    if (edges[v][i].first != p) dfs(edges[v][i].first, v, h + 1);
  }
}
int lca(int a, int b) {
  if (height[a] > height[b]) swap(a, b);
  if (height[a] < height[b]) {
    int log = logtable[height[b]];
    for (int i = log; i >= 0; i--) {
      if (height[b] - (1 << i) >= height[a]) b = dp[b][i];
    }
  }
  if (a != b) {
    int log = logtable[height[a]];
    for (int i = log; i >= 0; i--) {
      if (dp[a][i] != dp[b][i]) {
        a = dp[a][i], b = dp[b][i];
      }
    }
    a = parent[a];
  }
  return a;
}
int dfs2(int v) {
  int tot = values[v];
  int s;
  for (int i = 0; i < edges[v].size(); i++) {
    if (edges[v][i].first != parent[v]) {
      s = dfs2(edges[v][i].first);
      tot += s;
      edges2.push_back(make_pair(s, edges[v][i].second));
    }
  }
  return tot;
}
int main() {
  ios_base::sync_with_stdio(0);
  int N, a, b;
  cin >> N;
  logtable[0] = -1;
  for (int i = 1; i < N + 1; i++) {
    logtable[i] = logtable[i - 1];
    if ((i & -i) == i) {
      logtable[i]++;
    }
  }
  for (int i = 0; i < N - 1; i++) {
    cin >> a;
    cin >> b;
    ;
    edges[a].push_back(make_pair(b, i));
    edges[b].push_back(make_pair(a, i));
  }
  dfs(1, 0, 0);
  int K;
  cin >> K;
  for (int i = 0; i < K; i++) {
    cin >> a;
    cin >> b;
    ;
    values[a]++, values[b]++, values[lca(a, b)] -= 2;
  }
  dfs2(1);
  sort(edges2.begin(), edges2.end(), comp);
  for (int i = 0; i < N - 1; i++) {
    cout << edges2[i].first << " ";
  }
  cout << endl;
  return 0;
}
