#include <bits/stdc++.h>
using namespace std;
int mark[100005];
bool vis[200005];
pair<int, int> ed[200005];
vector<int> adj[200005], lev[100005];
int par[200005][20], he[200005][20], de[200005];
void dfs(int node, int p, int d) {
  lev[d].push_back(node);
  vis[node] = true;
  if (p != -1) {
    par[node][0] = p;
    for (int i = 1; i < 20; i++) {
      if (par[node][i - 1] != -1) {
        par[node][i] = par[par[node][i - 1]][i - 1];
      }
    }
  }
  de[node] = d;
  for (int it : adj[node]) {
    if (!vis[it]) {
      dfs(it, node, d + 1);
    }
  }
}
int lca(int u, int v) {
  if (de[u] < de[v]) {
    swap(u, v);
  }
  int i, ma = 0;
  if (de[u] != de[v]) {
    for (i = 20 - 1; i >= 0; i--) {
      if (par[u][i] != -1 && de[par[u][i]] >= de[v]) {
        ma = max(ma, he[u][i]);
        u = par[u][i];
      }
    }
  }
  if (v == u) return u;
  for (i = 20 - 1; i >= 0; i--) {
    if (par[u][i] != -1 && par[u][i] != par[v][i]) {
      ma = max({ma, he[u][i], he[v][i]});
      u = par[u][i];
      v = par[v][i];
    }
    ma = max({ma, he[u][0], he[v][0]});
  }
  return par[u][0];
}
map<int, int> mpa[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int u, v, i, j, k, l, m, n, t, r, cnt;
  int flag = 0;
  long long ans = 0, an = 0;
  t = 1;
  while (t--) {
    cin >> n;
    for (i = 0; i < n - 1; i++) {
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
      ed[i] = make_pair(u, v);
    }
    dfs(1, -1, 0);
    cin >> k;
    while (k--) {
      cin >> u >> v;
      mark[lca(u, v)] -= 2;
      mark[u] += 1;
      mark[v] += 1;
    }
    for (i = 100000; i > 0; i--) {
      for (int it : lev[i]) {
        mark[par[it][0]] += mark[it];
        mpa[it][par[it][0]] = mpa[par[it][0]][it] = mark[it];
      }
    }
    for (i = 0; i < n - 1; i++) {
      pair<int, int> it = ed[i];
      cout << mpa[it.first][it.second] << " ";
    }
    cout << endl;
  }
}
