#include <bits/stdc++.h>
using namespace std;
long long int dif(long long int a, long long int b) {
  return ((a / b) + (a % b != 0));
}
vector<long long int> v[200200];
long long int par[200200][19], dep[200200];
queue<long long int> q;
bool vi[200200], vip[200200], flag[200200];
long long int n, m, x, y, k;
long long int use[200200], sol[200200], order[400400];
long long int ford[200200];
void get_tree(long long int n) {
  long long int x, y;
  for (long long int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    order[k] = x;
    k++;
    order[k] = y;
    k++;
  }
}
long long int jump(long long int u, long long int k) {
  for (long long int i = 0; i < 19; i++) {
    if (k & (1 << i)) u = par[u][i];
  }
  return u;
}
void fill_par(long long int n) {
  for (long long int j = 1; j <= 18; j++) {
    for (long long int i = 1; i <= n; i++) {
      par[i][j] = par[par[i][j - 1]][j - 1];
    }
  }
}
void bfs(long long int s) {
  vi[s] = true;
  q.push(s);
  dep[s] = 0;
  par[s][0] = s;
  while (!q.empty()) {
    long long int h = q.front();
    q.pop();
    vi[h] = true;
    for (auto r : v[h]) {
      if (vi[r]) continue;
      q.push(r);
      vi[r] = true;
      par[r][0] = h;
      dep[r] = dep[h] + 1;
    }
  }
}
long long int lca(long long int u, long long int v) {
  if (dep[u] < dep[v]) swap(u, v);
  u = jump(u, dep[u] - dep[v]);
  if (u == v) return u;
  for (long long int i = 17; i >= 0; i--) {
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  }
  return par[u][0];
}
void get_inf(long long int m) {
  long long int x, y, h;
  for (long long int i = 0; i < m; i++) {
    cin >> x >> y;
    h = lca(x, y);
    use[x]++;
    use[y]++;
    use[h] -= 2;
  }
}
long long int dfs(long long int u) {
  if (vip[u]) return 0;
  vip[u] = true;
  long long int cur = use[u];
  for (auto r : v[u]) {
    cur += dfs(r);
  }
  sol[u] = cur;
  return cur;
}
void make_def(long long int n) {
  for (long long int i = 0; i < n + 1; i++) par[i][0] = i;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  make_def(n);
  get_tree(n);
  bfs(order[0]);
  fill_par(n);
  cin >> m;
  get_inf(m);
  dfs(order[0]);
  flag[order[0]] = true;
  for (long long int i = 0; i < 2 * n + 2; i += 2) {
    if (dep[order[i]] > dep[order[i + 1]])
      ford[i / 2] = order[i];
    else
      ford[i / 2] = order[i + 1];
  }
  for (long long int i = 0; i < n; i++) {
    if (ford[i] == 0) break;
    if (!flag[ford[i]]) {
      flag[ford[i]] = true;
      cout << sol[ford[i]] << " ";
    }
  }
  return 0;
}
