#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, k, a, b;
vector<int> g[N];
int lev[N], parent[20][N], d[N];
void dfs(int curr, int par, int x) {
  lev[curr] = x;
  parent[0][curr] = par;
  for (int p : g[curr]) {
    if (p != par) dfs(p, curr, x + 1);
  }
}
void precompute() {
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      if (parent[i - 1][j]) parent[i][j] = parent[i - 1][parent[i - 1][j]];
    }
  }
}
int LCA(int u, int v) {
  if (lev[u] < lev[v]) swap(u, v);
  int diff = lev[u] - lev[v];
  for (int i = 20 - 1; i >= 0; i--) {
    if ((1 << i) & diff) {
      u = parent[i][u];
    }
  }
  if (u == v) return u;
  for (int i = 20 - 1; i >= 0; i--) {
    if (parent[i][u] && parent[i][u] != parent[i][v]) {
      u = parent[i][u];
      v = parent[i][v];
    }
  }
  return parent[0][u];
}
map<pair<int, int>, int> val;
map<int, pair<int, int> > id;
int updates(int curr, int par) {
  int value = 0;
  for (int x : g[curr]) {
    if (x != par) {
      value += updates(x, curr);
    }
  }
  value += d[curr];
  if (curr > par) swap(curr, par);
  val[{curr, par}] = value;
  return value;
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
    if (a > b) swap(a, b);
    id[i] = {a, b};
  }
  dfs(1, 0, 0);
  precompute();
  cin >> k;
  while (k--) {
    cin >> a >> b;
    int p = LCA(a, b);
    if (p == a || p == b) {
      int v = a + b - p;
      d[v]++;
      d[p]--;
    } else {
      d[a]++, d[b]++, d[p] -= 2;
    }
  }
  updates(1, 0);
  for (int i = 1; i < n; i++) {
    cout << val[id[i]] << ' ';
  }
  cout << '\n';
  return 0;
}
