#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> g;
vector<int> parent, s, h, hld_idx, head, edges;
vector<long long> seg_tree, lazy;
int cur_hld_idx = 0;
void dfs(int v, int p) {
  s[v] = 1;
  int u_max = -1, idx_max = -1;
  for (auto [u, idx] : g[v]) {
    if (u != p) {
      dfs(u, v);
      if (u_max == -1 || (u_max != -1 && s[u_max] < s[u])) {
        u_max = u;
        idx_max = idx;
      }
      s[v] += s[u];
    }
  }
  if (g[v].size() == 1 && v != 0) {
    return;
  }
  vector<pair<int, int>> tmp = vector<pair<int, int>>((int)g[v].size());
  tmp[0] = {u_max, idx_max};
  int ptr = 1;
  for (auto [u, idx] : g[v]) {
    if (u != u_max) {
      tmp[ptr] = {u, idx};
      ++ptr;
    }
  }
  g[v] = tmp;
}
void dfs_hld(int v, bool first_in_chain, int par_hld_idx, int p) {
  int number = 0;
  for (auto [u, idx] : g[v]) {
    if (u != p) {
      hld_idx[u] = ++cur_hld_idx;
      edges[cur_hld_idx - 1] = idx;
      h[hld_idx[u]] = h[par_hld_idx] + 1;
      parent[hld_idx[u]] = par_hld_idx;
      if (number == 0) {
        if (first_in_chain) {
          head[cur_hld_idx - 1] = cur_hld_idx - 1;
        } else {
          head[cur_hld_idx - 1] = head[hld_idx[v] - 1];
        }
        dfs_hld(u, false, hld_idx[u], v);
      } else {
        head[cur_hld_idx - 1] = cur_hld_idx - 1;
        dfs_hld(u, true, hld_idx[u], v);
      }
    }
    ++number;
  }
}
void init(int n) {
  int len = 2 * pow(2.0, floor(log2(n) + 1));
  seg_tree.resize(len);
  lazy.resize(len);
}
void update(int v, int tl, int tr, int l, int r, long long delta) {
  int m = tl + (tr - tl) / 2;
  int left = 2 * v, right = 2 * v + 1;
  if (lazy[v] != 0) {
    seg_tree[v] += lazy[v] * (tr - tl + 1);
    if (tl < tr) {
      lazy[left] += lazy[v];
      lazy[right] += lazy[v];
    }
    lazy[v] = 0;
  }
  if (tl > r || tr < l) {
    return;
  }
  if (l <= tl && tr <= r) {
    seg_tree[v] += delta * (tr - tl + 1);
    if (tl < tr) {
      lazy[left] += delta;
      lazy[right] += delta;
    }
    return;
  }
  update(left, tl, m, l, r, delta);
  update(right, m + 1, tr, l, r, delta);
  seg_tree[v] = seg_tree[left] + seg_tree[right];
}
long long query(int v, int tl, int tr, int l, int r) {
  int m = tl + (tr - tl) / 2;
  int left = 2 * v, right = 2 * v + 1;
  if (lazy[v] != 0) {
    seg_tree[v] += lazy[v] * (tr - tl + 1);
    if (tl < tr) {
      lazy[left] += lazy[v];
      lazy[right] += lazy[v];
    }
    lazy[v] = 0;
  }
  if (tl > r || tr < l) {
    return 0ll;
  }
  if (l <= tl && tr <= r) {
    return seg_tree[v];
  }
  return query(left, tl, m, l, r) + query(right, m + 1, tr, l, r);
}
void update_path(int v, int u) {
  int n = g.size();
  v = hld_idx[v] - 1, u = hld_idx[u] - 1;
  int head_v = head[max(v, 0)], head_u = head[max(u, 0)];
  while (parent[v + 1] != parent[u + 1] && head_v != head_u &&
         parent[head_u + 1] != v + 1 && parent[head_v + 1] != u + 1) {
    if (h[head_v + 1] > h[head_u + 1]) {
      update(1, 0, n - 2, head_v, v, 1);
      v = parent[head_v + 1] - 1;
      head_v = head[max(v, 0)];
    } else {
      update(1, 0, n - 2, head_u, u, 1);
      u = parent[head_u + 1] - 1;
      head_u = head[max(u, 0)];
    }
  }
  if (v < u) {
    swap(v, u);
    swap(head_v, head_u);
  }
  if (parent[head_v + 1] == u + 1) {
    update(1, 0, n - 2, head_v, v, 1);
  } else if (head_v == head_u) {
    if (v == -1) {
      v = head_u;
      head_v = head[max(v, 0)];
    }
    if (u == -1) {
      u = head_v;
      head_u = head[max(u, 0)];
    }
    if (v != u) {
      update(1, 0, n - 2, u + 1, v, 1);
    }
  } else {
    update(1, 0, n - 2, v, v, 1);
    update(1, 0, n - 2, u, u, 1);
  }
}
void solve() {
  int n;
  cin >> n;
  g = vector<vector<pair<int, int>>>(n);
  h = s = parent = hld_idx = vector<int>(n);
  head = edges = vector<int>(n - 1);
  head[0] = -1;
  for (int i = 0; i < n - 1; ++i) {
    int v, u;
    cin >> v >> u;
    --v;
    --u;
    g[v].push_back({u, i});
    g[u].push_back({v, i});
  }
  dfs(0, -1);
  dfs_hld(0, true, 0, -1);
  init(n - 1);
  int k;
  cin >> k;
  for (int i = 0; i < k; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (a != b) {
      update_path(a, b);
    }
  }
  vector<int> ans(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    ans[edges[i]] = query(1, 0, n - 2, i, i);
  }
  for (int i = 0; i < n - 1; ++i) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
