#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e15;
const int M = 1e9 + 7;
long long int sum[500000];
long long int sub_sum[500000];
int main() {
  long long int T, n, a, b, c, q, tmp = 0;
  T = 1;
  while (T--) {
    cin >> n;
    std::vector<pair<long long int, long long int>> roads;
    std::vector<int> g[n + 2];
    std::vector<vector<int>> lift(n + 2);
    for (int i = 0; i < n - 1; ++i) {
      cin >> a >> b;
      g[a].emplace_back(b);
      g[b].emplace_back(a);
      roads.emplace_back(a, b);
    }
    std::vector<int> dep(n + 1, 0);
    std::vector<bool> vis(n + 1, false);
    lift[0].emplace_back(0);
    lift[1].emplace_back(0);
    function<void(int, int)> dfs = [&](int node, int d) {
      vis[node] = true;
      dep[node] = d;
      for (auto u : g[node]) {
        if (!vis[u]) {
          lift[u].emplace_back(node);
          dfs(u, d + 1);
        }
      }
    };
    dfs(1, 0);
    for (int i = 1; i <= 18; ++i)
      for (int j = 0; j <= n; ++j)
        lift[j].emplace_back(lift[lift[j][i - 1]][i - 1]);
    cin >> q;
    while (q--) {
      cin >> a >> b;
      if (dep[a] > dep[b]) swap(a, b);
      int n2 = b, n1 = a;
      int shift = abs(dep[a] - dep[b]);
      int k = 0;
      while (shift > 0) {
        if (shift & 1) n2 = lift[n2][k];
        shift /= 2;
        k++;
      }
      function<int(int, int)> find_lca = [&](int x, int y) {
        if (lift[x][0] == lift[y][0]) return lift[x][0];
        int l = 1;
        while (1) {
          if (lift[x][l] == lift[y][l]) {
            return find_lca(lift[x][l - 1], lift[y][l - 1]);
            break;
          }
          l++;
        }
      };
      int lca = (n2 == a) ? a : find_lca(a, n2);
      sum[a] += 1;
      sum[b] += 1;
      sum[lca] -= 2;
    }
    for (auto i : vis) i = false;
    function<long long int(int)> sub_dfs = [&](int node) {
      vis[node] = true;
      int res = sum[node];
      for (auto u : g[node]) {
        if (!vis[u]) res += sub_dfs(u);
      }
      sub_sum[node] = res;
      return res;
    };
    sub_dfs(1);
    for (auto [i, j] : roads) {
      if (dep[i] < dep[j])
        cout << sub_sum[j] << " ";
      else
        cout << sub_sum[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
