#include <bits/stdc++.h>
using namespace std;
long long l = 35;
long long up[100001][36];
long long tin[100001];
long long tout[100001];
long long timer = 0;
vector<pair<long long, long long> > ed2[100001];
vector<long long> ed[100001];
void dfs(long long src, vector<long long> ed[], long long par) {
  tin[src] = timer;
  timer++;
  up[src][0] = par;
  for (long long i = (1), _b = (l); i <= _b; i++) {
    up[src][i] = up[up[src][i - 1]][i - 1];
  }
  for (long long i = 0, _n = (ed[src].size()); i < _n; i++) {
    if (ed[src][i] != par) dfs(ed[src][i], ed, src);
  }
  tout[src] = timer;
}
bool isAncestor(long long u, long long v) {
  if (tin[u] <= tin[v] && tout[u] >= tout[v]) return true;
  return false;
}
long long lca(long long u, long long v) {
  if (isAncestor(u, v)) return u;
  if (isAncestor(v, u)) return v;
  for (long long i = (l), _b = (0); i >= _b; i--) {
    if (!isAncestor(up[u][i], v)) u = up[u][i];
  }
  return up[u][0];
}
long long val[100001];
long long ans[100001];
long long DFS2(long long src, long long par) {
  for (long long i = 0, _n = (ed2[src].size()); i < _n; i++) {
    if (ed2[src][i].first != par) {
      long long node = ed2[src][i].first;
      long long ind = ed2[src][i].second;
      long long sum = DFS2(ed[src][i], src);
      val[src] += sum;
      ans[ind] = sum;
    }
  }
  return val[src];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 0, _n = (n - 1); i < _n; i++) {
    long long a, b;
    cin >> a >> b;
    ed[a].push_back(b);
    ed[b].push_back(a);
    ed2[a].push_back(make_pair(b, i));
    ed2[b].push_back(make_pair(a, i));
  }
  dfs(1, ed, 1);
  long long k;
  cin >> k;
  for (long long i = 0, _n = (k); i < _n; i++) {
    long long a, b;
    cin >> a >> b;
    long long lc = lca(a, b);
    val[lc] -= 2;
    val[a]++;
    val[b]++;
  }
  DFS2(1, 1);
  for (long long i = 0, _n = (n - 1); i < _n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}
