#include <bits/stdc++.h>
using namespace std;
void dfs(long long node, long long parent, long long ancestors[][21],
         long long levels[], long long log, vector<vector<long long> >& graph) {
  ancestors[node][0] = parent;
  for (long long i = 1; i <= log; i++) {
    if (ancestors[node][i - 1] == -1) break;
    ancestors[node][i] = ancestors[ancestors[node][i - 1]][i - 1];
  }
  for (long long i = 0; i < graph[node].size(); i++) {
    long long curNode = graph[node][i];
    if (parent != curNode) {
      levels[curNode] = levels[node] + 1;
      dfs(curNode, node, ancestors, levels, log, graph);
    }
  }
}
long long lca(long long u, long long v, long long log, long long levels[],
              long long ancestors[][21]) {
  u--;
  v--;
  if (levels[u] < levels[v]) {
    swap(u, v);
  }
  long long dist = levels[u] - levels[v];
  for (long long i = log; i >= 0; i--) {
    if (levels[u] - levels[v] >= pow(2, i)) {
      u = ancestors[u][i];
    }
  }
  if (u == v) return u;
  for (long long i = log; i >= 0; i--) {
    if (ancestors[u][i] != ancestors[v][i]) {
      u = ancestors[u][i];
      v = ancestors[v][i];
    }
  }
  return ancestors[u][0];
}
long long dfs2(long long node, long long parent,
               vector<vector<long long> >& graph,
               map<pair<long long, long long>, long long>& mp,
               long long nums[]) {
  long long curRes = nums[node];
  for (long long i = 0; i < graph[node].size(); i++) {
    long long curNode = graph[node][i];
    if (curNode != parent) {
      long long res = dfs2(curNode, node, graph, mp, nums);
      mp[make_pair(node, curNode)] = res;
      mp[make_pair(curNode, node)] = res;
      curRes += res;
    }
  }
  return curRes;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<vector<long long> > graph(n, vector<long long>());
  map<pair<long long, long long>, long long> mp;
  vector<pair<long long, long long> > edges;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
    edges.push_back(make_pair(u, v));
  }
  long long log = 20;
  long long ancestors[n][21];
  long long levels[n];
  memset(ancestors, -1, sizeof(ancestors));
  memset(levels, 0, sizeof(levels));
  dfs(0, -1, ancestors, levels, log, graph);
  long long k;
  cin >> k;
  long long nums[n];
  memset(nums, 0, sizeof(nums));
  for (long long i = 0; i < k; i++) {
    long long a, b;
    cin >> a >> b;
    nums[a - 1]++;
    nums[b - 1]++;
    long long ancestor = lca(a, b, log, levels, ancestors);
    nums[ancestor] -= 2;
  }
  dfs2(0, -1, graph, mp, nums);
  std::map<pair<long long, long long>, long long>::iterator it;
  for (long long i = 0; i < edges.size(); i++) {
    pair<long long, long long> curp = edges[i];
    cout << mp[curp] << " ";
  }
  return 0;
}
