#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> a[N], in(N), out(N), val(N, 0);
pair<int, int> p[N];
map<pair<int, int>, int> m;
vector<vector<int> > par(N, vector<int>(log2(N) + 1));
int timer = 0;
void build(int x, int pa = -1) {
  in[x] = ++timer;
  par[x][0] = (pa == -1) ? x : pa;
  for (int i = 1; i <= log2(N); ++i) par[x][i] = par[par[x][i - 1]][i - 1];
  for (auto i : a[x])
    if (i != pa) build(i, x);
  out[x] = timer;
}
bool anc(int u, int v) { return (in[u] <= in[v]) && (out[u] >= out[v]); }
int lca(int u, int v) {
  if (anc(u, v)) return u;
  if (anc(v, u)) return v;
  for (int i = log2(N); i >= 0; --i)
    if (!anc(par[u][i], v)) u = par[u][i];
  return par[u][0];
}
int dfs(int x, int pa = -1) {
  int cnt = 0;
  for (auto i : a[x]) {
    if (i != pa) {
      int tmp = dfs(i, x);
      if (i > x)
        m[make_pair(x, i)] += tmp;
      else
        m[make_pair(i, x)] += tmp;
      cnt += tmp;
    }
  }
  return cnt + val[x];
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    p[i] = {u, v};
    a[u].push_back(v);
    a[v].push_back(u);
  }
  build(1);
  int k;
  cin >> k;
  for (int i = 0; i < k; ++i) {
    int u, v;
    cin >> u >> v;
    int x = lca(u, v);
    val[x] -= 2;
    val[u]++, val[v]++;
  }
  dfs(1);
  for (int i = 0; i < n - 1; ++i) cout << m[p[i]] << " ";
}
