#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
const int NN = 40;
vector<int> a[N];
vector<pair<int, int> > edge;
int p[N][NN], sum[N], h[N];
void dfs(int v, int par, int hei) {
  h[v] = hei;
  p[v][0] = par;
  for (int i = 1; i < NN; i++)
    if (p[v][i - 1] != -1) p[v][i] = p[p[v][i - 1]][i - 1];
  for (int i = 0; i < a[v].size(); i++) {
    if (a[v][i] != par) {
      dfs(a[v][i], v, hei + 1);
      sum[v] += sum[a[v][i]];
    }
  }
}
int getp(int v, int k) {
  for (int i = 0; i < NN; i++) {
    if (k % 2 == 1) v = p[v][i];
    k /= 2;
  }
  return v;
}
int lcs(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  u = getp(u, h[u] - h[v]);
  if (u == v) return v;
  for (int i = NN - 1; i >= 0; i--) {
    if (p[v][i] != p[u][i]) {
      u = p[u][i], v = p[v][i];
    }
  }
  return p[v][0];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(p, -1, sizeof(p));
  int n;
  cin >> n;
  for (int i = 0, u, v; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    edge.push_back(make_pair(u, v));
    a[u].push_back(v);
    a[v].push_back(u);
  }
  dfs(0, -1, 0);
  int k;
  cin >> k;
  for (int i = 0, u, v; i < k; i++) {
    cin >> u >> v;
    u--;
    v--;
    int s = lcs(u, v);
    sum[v]++;
    sum[u]++;
    sum[s] -= 2;
  }
  dfs(0, -1, 0);
  for (int i = 0, u, v; i < n - 1; i++) {
    u = edge[i].first, v = edge[i].second;
    if (h[u] > h[v]) swap(u, v);
    cout << sum[v] << " ";
  }
  cout << "\n";
  return 0;
}
