#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int LGN = 19;
vector<pair<int, int> > G[MAXN];
vector<int> upd[MAXN];
int par[MAXN][LGN], depth[MAXN], x[MAXN], ans[MAXN];
void dfs(int pos, int prev) {
  depth[pos] = 1 + depth[prev];
  par[pos][0] = prev;
  for (int i = 0; i < G[pos].size(); ++i) {
    if (G[pos][i].first != prev) dfs(G[pos][i].first, pos);
  }
}
void dfs_upd(int pos, int prev, int e) {
  int ret = 0;
  for (int i = 0; i < G[pos].size(); ++i) {
    if (G[pos][i].first != prev) {
      dfs_upd(G[pos][i].first, pos, G[pos][i].second);
    }
  }
  ans[e] = x[pos];
  x[prev] = x[prev] + x[pos];
  return;
}
int lca(int u, int v) {
  if (depth[u] < depth[v]) return lca(v, u);
  int diff = depth[u] - depth[v];
  for (int i = 0; i < LGN; ++i) {
    if (diff & (1 << i)) {
      u = par[u][i];
    }
  }
  if (u == v) return u;
  for (int i = LGN - 1; i >= 0; --i) {
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  }
  return par[u][0];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    G[u].push_back(pair<int, int>(v, i));
    G[v].push_back(pair<int, int>(u, i));
  }
  dfs(1, 0);
  for (int j = 1; j < LGN; ++j) {
    for (int i = 1; i <= n; ++i) {
      par[i][j] = par[par[i][j - 1]][j - 1];
    }
  }
  int k;
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    int l = lca(u, v);
    if (l == u || l == v) {
      if (l == u) {
        x[u] += -1;
        x[v] += 1;
      }
      if (l == v) {
        x[v] += -1;
        x[u] += 1;
      }
    } else {
      x[l] += -2;
      x[u] += 1;
      x[v] += 1;
    }
  }
  dfs_upd(1, 0, n + 1);
  for (int i = 0; i < n - 1; ++i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
