#include <bits/stdc++.h>
using namespace std;
const long long N = 300000;
int keep[N], tin[N], tout[N], up[N][21], w[N], timer;
int n, m, x, y;
vector<int> g[N], num[N];
void ans(int v, int p) {
  for (int i = 0; i < g[v].size(); ++i) {
    if (g[v][i] == p) continue;
    ans(g[v][i], v);
    w[v] += w[g[v][i]];
    keep[num[v][i]] += w[g[v][i]];
  }
}
void dfs(int v, int p) {
  up[v][0] = p;
  tin[v] = ++timer;
  for (int i = 1; i <= 20; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  for (int i = 0; i < g[v].size(); ++i)
    if (g[v][i] != p) dfs(g[v][i], v);
  tout[v] = ++timer;
}
bool ok(int x, int y) { return tin[x] <= tin[y] && tout[x] >= tout[y]; }
int lca(int x, int y) {
  if (ok(x, y)) return x;
  if (ok(y, x)) return y;
  for (int i = 20; i >= 0; --i)
    if (!ok(up[x][i], y)) x = up[x][i];
  return up[x][0];
}
int main() {
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> x >> y;
    g[x].push_back(y);
    num[x].push_back(i);
    g[y].push_back(x);
    num[y].push_back(i);
  }
  dfs(1, 1);
  cin >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> x >> y;
    ++w[x];
    ++w[y];
    w[lca(x, y)] -= 2;
  }
  ans(1, 1);
  for (int i = 1; i < n; ++i) cout << keep[i] << ' ';
}
