#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010, maxk = 19;
vector<int> G[maxn];
int p[maxn][maxk], h[maxn], sum[maxn];
vector<pair<int, int> > Edg;
int n;
void dfs(int v) {
  for (int i = 0; i < (int)G[v].size(); ++i) {
    int u = G[v][i];
    if (p[v][0] != u) {
      p[u][0] = v;
      h[u] = h[v] + 1;
      dfs(u);
    }
  }
}
int LCA(int u, int v) {
  if (h[u] < h[v]) {
    swap(u, v);
  }
  for (int i = maxk - 1; i >= 0; --i) {
    if ((h[u] - (1 << i)) >= h[v]) {
      u = p[u][i];
    }
  }
  if (u == v) {
    return u;
  }
  for (int i = maxk - 1; i >= 0; --i) {
    if (p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  }
  return p[u][0];
}
void dfsS(int v) {
  for (int i = 0; i < (int)G[v].size(); ++i) {
    int u = G[v][i];
    if (u != p[v][0]) {
      dfsS(u);
      sum[v] += sum[u];
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    G[u].push_back(v);
    G[v].push_back(u);
    Edg.push_back(make_pair(u, v));
  }
  dfs(0);
  for (int k = 1; k < maxk; ++k) {
    for (int i = 0; i < n; ++i) {
      p[i][k] = p[p[i][k - 1]][k - 1];
    }
  }
  int k;
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) {
    int u, v, Lca;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    Lca = LCA(u, v);
    sum[Lca] -= 2;
    sum[u] += 1;
    sum[v] += 1;
  }
  dfsS(0);
  for (int i = 0; i < n - 1; ++i) {
    int res;
    if (h[Edg[i].first] > h[Edg[i].second]) {
      res = sum[Edg[i].first];
    } else {
      res = sum[Edg[i].second];
    }
    printf("%d ", res);
  }
}
