#include <bits/stdc++.h>
using pii = std::pair<long long, long long>;
using namespace std;
long long n, k, u, v, visited[100005], first[100005], parent[100005] = {0},
                                                      travels[100005] = {0};
vector<long long> euler, adj[100005];
map<pii, long long> dist;
map<long long, set<long long>, greater<long long>> node_by_height;
vector<pii> height;
pii edges[100005], st[400005];
class CFoolsAndRoads {
 public:
  void solve(std::istream& in, std::ostream& out) {
    in >> n;
    for (long long i = (0); i < (n - 1); i++) {
      in >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
      edges[i] = {u, v};
    }
    et(1, 0);
    build();
    in >> k;
    for (long long i = (0); i < (k); i++) {
      in >> u >> v;
      long long l = first[u], r = first[v];
      long long lca = euler[query(min(l, r), max(l, r) + 1)];
      travels[u]++;
      travels[v]++;
      travels[lca] -= 2;
    }
    for (auto ht : node_by_height) {
      if (ht.first == 0) break;
      for (auto node : ht.second) {
        dist[{node, parent[node]}] = travels[node];
        travels[parent[node]] += travels[node];
      }
    }
    for (long long i = (0); i < (n - 1); i++)
      out << max(dist[{edges[i].first, edges[i].second}],
                 dist[{edges[i].second, edges[i].first}])
          << " ";
    out << "\n";
  }
  void et(long long x, long long h) {
    visited[x] = 1;
    first[x] = euler.size();
    node_by_height[h].insert(x);
    height.emplace_back(h, euler.size());
    euler.push_back(x);
    for (auto v : adj[x])
      if (!visited[v]) {
        et(v, h + 1);
        parent[v] = x;
        height.emplace_back(h, euler.size());
        euler.push_back(x);
      }
  }
  void build() {
    for (long long i = (0); i < (height.size()); i++)
      st[height.size() + i] = height[i];
    for (long long i = height.size() - 1; i >= 0; i--)
      st[i] = min(st[2 * i], st[2 * i + 1]);
  }
  long long query(long long l, long long r) {
    pii ans = {1e9, 1e9};
    for (l += height.size(), r += height.size(); l < r; l >>= 1, r >>= 1) {
      if (l & 1) {
        if (st[l].first < ans.first) ans = st[l];
        l++;
      }
      if (r & 1)
        if (st[--r].first < ans.first) ans = st[r];
    }
    return ans.second;
  }
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  CFoolsAndRoads solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
