#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
const int oo = 1e9;
const int mod = 1e9 + 7;
vector<int> g[N];
int f[N][18], depth[N], cnt[N];
bool leaf[N];
map<int, int> num[N];
void dfs(int idx) {
  int p = 0;
  for (int i = 0; i < g[idx].size(); i++) {
    int v = g[idx][i];
    if (v == f[idx][0]) continue;
    depth[v] = depth[idx] + 1;
    f[v][0] = idx;
    dfs(v);
    p++;
  }
  if (!p) leaf[idx] = 1;
}
int kth(int u, int k) {
  for (int i = 17; i >= 0; i--)
    if ((k >> i) & 1) u = f[u][i];
  return u;
}
int lca(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  int l = depth[u] - depth[v];
  u = kth(u, l);
  if (u == v) return u;
  for (int i = 17; i >= 0; i--) {
    if (f[u][i] != f[v][i]) {
      u = f[u][i];
      v = f[v][i];
    }
  }
  return f[u][0];
}
int count(int idx, int sum) {
  int r = 0, s = 0;
  if (g[idx].size() == 1 && g[idx][0] == f[idx][0]) return sum;
  for (int i = 0; i < g[idx].size(); i++) {
    int v = g[idx][i];
    if (v == f[idx][0]) continue;
    sum += cnt[v];
    r = count(v, cnt[v]);
    s += r;
    num[idx][v] = r;
    num[v][idx] = r;
    sum -= cnt[v];
  }
  return s + cnt[idx];
}
int main() {
  vector<pair<int, int>> ans;
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    ans.push_back({u, v});
  }
  dfs(1);
  for (int i = 1; i < 18; i++)
    for (int j = 1; j <= n; j++) f[j][i] = f[f[j][i - 1]][i - 1];
  scanf("%d", &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (depth[u] < depth[v]) swap(u, v);
    int l = lca(u, v);
    cnt[u]++;
    cnt[v]++;
    cnt[l] -= 2;
  }
  count(1, 0);
  for (int i = 0; i < ans.size(); i++) {
    printf("%d ", num[ans[i].first][ans[i].second]);
  }
  puts("");
}
