#include <bits/stdc++.h>
using namespace std;
const int M = 100100;
int n, q, b[M * 4], p[M * 4], g[M], h[M], k = 2, r[M], d[M], t[M];
int rt(int x) { return x == r[x] ? x : (r[x] = rt(r[x])); }
void ad(int* e, int x, int y) {
  b[k] = y, p[k] = e[x], e[x] = k++;
  b[k] = x, p[k] = e[y], e[y] = k++;
}
void go(int x) {
  r[x] = x;
  for (int i = h[x]; i > 0; i = p[i]) {
    ++d[x];
    if (r[b[i]]) d[rt(b[i])] -= 2;
  }
  for (int i = g[x]; i > 0; i = p[i])
    if (!r[b[i]]) {
      go(b[i]);
      d[x] += (t[i / 2] = d[b[i]]);
      r[b[i]] = x;
    }
}
int main(void) {
  cin >> n;
  for (int i = 1, x, y; i < n && cin >> x >> y; ++i) ad(g, x, y);
  cin >> q;
  for (int i = 0, x, y; i < q && cin >> x >> y; ++i)
    if (x != y) ad(h, x, y);
  go(1);
  for (int i = 1; i < n; ++i) cout << (i > 1 ? " " : "") << t[i];
  cout << endl;
}
