#include <bits/stdc++.h>
using namespace std;
int n, t, l, k, x, y, z, b[100015], up[100015][20], tin[100015], tout[100015],
    rez[100015];
vector<int> a[100015], nr[100015];
void dfs1(int v, int p) {
  tin[v] = ++t;
  up[v][0] = p;
  for (int i = 1; i <= l; ++i) {
    up[v][i] = up[up[v][i - 1]][i - 1];
  }
  for (int u : a[v]) {
    if (u != p) {
      dfs1(u, v);
    }
  }
  tout[v] = ++t;
}
bool is_ancestor(int u, int v) {
  return tin[u] <= tin[v] && tout[u] >= tout[v];
}
int lca(int u, int v) {
  if (is_ancestor(u, v)) {
    return u;
  }
  if (is_ancestor(v, u)) {
    return v;
  }
  for (int i = l; i >= 0; --i) {
    if (!is_ancestor(up[u][i], v)) {
      u = up[u][i];
    }
  }
  return up[u][0];
}
void dfs2(int v, int p, int c) {
  for (int i = 0; i < a[v].size(); ++i) {
    if (a[v][i] != p) {
      dfs2(a[v][i], v, nr[v][i]);
      rez[c] += rez[nr[v][i]];
    }
  }
  rez[c] += b[v];
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    cin >> x >> y;
    a[x].push_back(y);
    nr[x].push_back(i + 1);
    a[y].push_back(x);
    nr[y].push_back(i + 1);
  }
  l = ceil(log2(n));
  dfs1(1, 1);
  cin >> k;
  for (int i = 0; i < k; ++i) {
    cin >> x >> y;
    z = lca(x, y);
    b[z] -= 2;
    ++b[x];
    ++b[y];
  }
  dfs2(1, 1, 0);
  for (int i = 1; i < n; ++i) {
    cout << rez[i] << " ";
  }
  return 0;
}
