#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10 + 100000;
const int INF = int(1e9);
int n, m, res;
int h[MAXN], sum[MAXN], par[MAXN][20], st[MAXN], fi[MAXN];
bool vis[MAXN];
vector<int> g[MAXN];
void init() {
  for (int i = (0), _b = (18); i <= _b; i++) par[1][i] = 1;
  h[1] = 1;
}
void dfs(int u) {
  if (u != 1) {
    for (int i = (1), _b = (18); i <= _b; i++)
      par[u][i] = par[par[u][i - 1]][i - 1];
  }
  for (typeof(g[u].begin()) it = (g[u].begin()); it != (g[u].end()); it++) {
    int v = *it;
    if (par[v][0] == 0) {
      par[v][0] = u;
      h[v] = h[u] + 1;
      dfs(v);
    }
  }
}
int lca(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  for (int i = (18), _b = (0); i >= _b; i--) {
    int uu = par[u][i];
    if (h[uu] >= h[v]) u = uu;
  }
  for (int i = (18), _b = (0); i >= _b; i--)
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  return (u == v) ? u : par[u][0];
}
void dfs_res(int u) {
  vis[u] = true;
  for (typeof(g[u].begin()) it = (g[u].begin()); it != (g[u].end()); it++) {
    int v = *it;
    if (!vis[v]) {
      dfs_res(v);
      sum[u] += sum[v];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = (0), _b = (n - 1); i < _b; i++) {
    cin >> st[i] >> fi[i];
    g[st[i]].push_back(fi[i]);
    g[fi[i]].push_back(st[i]);
  }
  memset(par, 0, sizeof(par));
  memset(vis, false, sizeof(vis));
  init();
  dfs(1);
  cin >> m;
  int u, v;
  for (int i = (0), _b = (m); i < _b; i++) {
    cin >> u >> v;
    int r = lca(u, v);
    sum[u]++;
    sum[v]++;
    sum[r] -= 2;
  }
  dfs_res(1);
  for (int i = (0), _b = (n - 1); i < _b; i++) {
    if (h[st[i]] > h[fi[i]])
      cout << sum[st[i]] << ' ';
    else
      cout << sum[fi[i]] << ' ';
  }
  return 0;
}
