#include <bits/stdc++.h>
using namespace std;
const int L = 20;
const int N = 2e5 + 3;
int ROOT = 1;
int n, q;
int in[N];
vector<pair<int, int> > ls[N];
int jp[N][L + 3];
int oj[N], d[N], dp[N], odw[N], T[N], wynik[N], nL[N];
void make_jp() {
  for (int i = 0; i <= L; i++) {
    jp[ROOT][i] = ROOT;
    jp[0][i] = ROOT;
  }
  for (int i = 0; i <= n; i++) {
    jp[i][0] = oj[i];
  }
  for (int p = 1; p <= L; p++) {
    for (int i = 1; i <= n; i++) {
      jp[i][p] = jp[jp[i][p - 1]][p - 1];
    }
  }
}
void dfs(int ten, int dpt) {
  odw[ten] = 1;
  d[ten] = dpt;
  for (int i = 0; i < ls[ten].size(); i++) {
    if (!odw[ls[ten][i].first]) {
      oj[ls[ten][i].first] = ten;
      dfs(ls[ten][i].first, dpt + 1);
    }
  }
}
void dfs2(int ten) {
  odw[ten] = 2;
  int sum = 0;
  dp[ten] = T[ten];
  for (int i = 0; i < ls[ten].size(); i++) {
    if (!(odw[ls[ten][i].first] == 2)) {
      dfs2(ls[ten][i].first);
      wynik[ls[ten][i].second] = dp[ls[ten][i].first];
      sum += dp[ls[ten][i].first];
    }
  }
  dp[ten] += sum - nL[ten];
}
int lca(int a, int b) {
  int a2 = a;
  int b2 = b;
  if (a == ROOT || b == ROOT) {
    return ROOT;
  }
  if (d[a2] < d[b2]) {
    swap(a, b);
  }
  for (int s = L; s >= 0; s--) {
    if (d[jp[a][s]] < d[b]) {
      continue;
    } else {
      a = jp[a][s];
    }
  }
  if (a == b) {
    return a;
  }
  for (int s = L; s >= 0; s--) {
    if (a == ROOT || b == ROOT) {
      return ROOT;
    }
    if (jp[a][s] == jp[b][s]) {
      continue;
    }
    if (a == ROOT || b == ROOT) {
      return ROOT;
    }
    a = jp[a][s];
    b = jp[b][s];
  }
  return jp[a][0];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int a, b;
    a = 0;
    b = 0;
    cin >> a >> b;
    ls[a].push_back({b, i});
    ls[b].push_back({a, i});
    in[a] += 1;
    in[b] += 1;
  }
  dfs(ROOT, 0);
  make_jp();
  cin >> q;
  for (int i = 1; i <= q; i++) {
    int a, b;
    cin >> a >> b;
    nL[lca(a, b)] += 2;
    T[a] += 1;
    T[b] += 1;
  }
  dfs2(ROOT);
  for (int i = 1; i <= n - 1; i++) {
    cout << wynik[i] << " ";
  }
  return 0;
}
