#include <bits/stdc++.h>
using namespace std;
int parent_table[100100][24], visited[100100], level[100100], val[100100],
    cnt[100100];
vector<int> A[100100];
map<pair<int, int>, int> edge;
void initialize(int n) {
  int i, j;
  for (i = 0; i <= n; i++) {
    visited[i] = false;
    for (j = 0; j < 24; j++) parent_table[i][j] = -1;
  }
  level[0] = 0;
}
void dfs(int n, int l) {
  int m = A[n].size(), i, v, sum = 0;
  visited[n] = true;
  level[n] = l;
  for (i = 0; i < m; i++) {
    v = A[n][i];
    if (!visited[v]) {
      parent_table[v][0] = n;
      dfs(v, l + 1);
    }
  }
}
void make_parent_table(int n) {
  int i, j;
  for (i = 1; i < 24; i++) {
    for (j = 1; j <= n; j++) {
      if (parent_table[j][i - 1] != -1)
        parent_table[j][i] = parent_table[parent_table[j][i - 1]][i - 1];
    }
  }
}
int LCA(int p, int q) {
  int i, j, temp;
  if (level[p] < level[q]) swap(p, q);
  for (i = 24 - 1; i >= 0; i--) {
    if (level[p] - (1 << i) >= level[q]) p = parent_table[p][i];
  }
  if (p == q) return p;
  for (i = 24 - 1; i >= 0; i--) {
    if (parent_table[p][i] != -1 && parent_table[p][i] != parent_table[q][i]) {
      p = parent_table[p][i];
      q = parent_table[q][i];
    }
  }
  return parent_table[p][0];
}
int call(int u) {
  int i, v, c, sum = 0;
  visited[u] = true;
  for (i = 0; i < A[u].size(); i++) {
    v = A[u][i];
    if (!visited[v]) {
      c = call(v);
      sum += c;
      cnt[edge[make_pair((((u) > (v)) ? (u) : (v)),
                         (((u) < (v)) ? (u) : (v)))]] = c;
    }
  }
  return sum + val[u];
}
int main() {
  int i, j, k, n, sum, temp, L, l;
  memset((visited), (0), sizeof(visited));
  memset((cnt), (0), sizeof(cnt));
  memset((val), (0), sizeof(val));
  scanf("%d", &n);
  initialize(n);
  for (i = 0; i < (n - 1); i++) {
    scanf("%d%d", &j, &k);
    edge[make_pair((((j) > (k)) ? (j) : (k)), (((j) < (k)) ? (j) : (k)))] =
        i + 1;
    A[j].push_back(k);
    A[k].push_back(j);
  }
  dfs(1, 0);
  make_parent_table(n);
  scanf("%d", &k);
  for (l = 1; l <= k; l++) {
    scanf("%d%d", &i, &j);
    L = LCA(i, j);
    val[i]++;
    val[j]++;
    val[L] -= 2;
  }
  memset((visited), (0), sizeof(visited));
  call(1);
  for (i = 1; i <= n - 1; i++) printf("%d ", cnt[i]);
  printf("\n");
  ;
  return 0;
}
