#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
const int logMAXN = 20;
int LCA[logMAXN][MAXN], parent[MAXN], subtree_sum[MAXN], edge_val[MAXN],
    depth[MAXN];
bool visited[MAXN];
vector<int> graph[MAXN], edge_idx[MAXN];
void generateParents(int, int);
void calculateEdgeValues(int);
void precomputeLCA(int);
int getLCA(int, int);
int main() {
  int n, a, b;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    edge_idx[a].push_back(i);
    graph[b].push_back(a);
    edge_idx[b].push_back(i);
  }
  parent[1] = -1;
  generateParents(1, 0);
  precomputeLCA(n);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    ++subtree_sum[a], ++subtree_sum[b];
    subtree_sum[getLCA(a, b)] -= 2;
  }
  calculateEdgeValues(1);
  for (int i = 0; i < n - 1; i++) cout << edge_val[i] << " ";
  cout << endl;
  return 0;
}
void generateParents(int src, int deep) {
  depth[src] = deep;
  for (auto v : graph[src]) {
    if (parent[v] == 0) {
      parent[v] = src;
      generateParents(v, deep + 1);
    }
  }
}
void calculateEdgeValues(int src) {
  visited[src] = 1;
  for (int i = 0; i < graph[src].size(); i++) {
    if (visited[graph[src][i]] == 0) {
      calculateEdgeValues(graph[src][i]);
      subtree_sum[src] += subtree_sum[graph[src][i]];
      edge_val[edge_idx[src][i]] = subtree_sum[graph[src][i]];
    }
  }
}
void precomputeLCA(int n) {
  for (int i = 0; i < logMAXN; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == 0)
        LCA[i][j] = parent[j];
      else {
        if (LCA[i - 1][j] != -1)
          LCA[i][j] = LCA[i - 1][LCA[i - 1][j]];
        else
          LCA[i][j] = -1;
      }
    }
  }
}
int getLCA(int x, int y) {
  if (depth[x] < depth[y]) swap(x, y);
  for (int i = logMAXN - 1; i >= 0 && (depth[x] != depth[y]); i--) {
    if (LCA[i][x] != -1 && depth[LCA[i][x]] >= depth[y]) {
      x = LCA[i][x];
    }
  }
  if (x == y) return x;
  int ans;
  for (int i = logMAXN - 1; i >= 0; i--) {
    if (LCA[i][x] != LCA[i][y]) {
      x = LCA[i][x];
      y = LCA[i][y];
    } else
      ans = LCA[i][x];
  }
  return ans;
}
