#include <bits/stdc++.h>
using namespace std;
std::vector<int> adjList[100001];
std::vector<int> T(100001, -1);
std::vector<int> L(100001, 0);
std::vector<int> visited(100001, 0);
std::vector<int> counti(100001, 0);
std::vector<int> countsubtree(100001, 0);
std::vector<pair<int, int> > edges;
int P[100005][19];
int LCA(int u, int v) {
  if (L[u] < L[v]) {
    swap(u, v);
  }
  int dist = L[u] - L[v];
  while (dist > 0) {
    int raise_by = log2(dist);
    u = P[u][raise_by];
    dist -= (1 << raise_by);
  }
  if (u == v) {
    return u;
  }
  for (int j = 18; j >= 0; --j) {
    if ((P[u][j] != -1) && (P[u][j] != P[v][j])) {
      u = P[u][j];
      v = P[v][j];
    }
  }
  return T[u];
}
void dfs(int s) {
  visited[s] = 1;
  for (int child : adjList[s]) {
    if (!visited[child]) {
      T[child] = s;
      L[child] = L[s] + 1;
      dfs(child);
    }
  }
}
void dfs2(int s) {
  visited[s] = 1;
  countsubtree[s] = counti[s];
  for (int child : adjList[s]) {
    if (!visited[child]) {
      dfs2(child);
      countsubtree[s] += countsubtree[child];
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
    edges.push_back(make_pair(u, v));
  }
  int i, j;
  dfs(1);
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; (1 << j) < n; ++j) {
      P[i][j] = -1;
    }
  }
  for (int i = 1; i <= n; ++i) {
    P[i][0] = T[i];
  }
  for (int j = 1; (1 << j) < n; ++j) {
    for (int i = 1; i <= n; ++i) {
      if (P[i][j - 1] != -1) {
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
  int k;
  cin >> k;
  for (int i = 0; i < k; ++i) {
    int u, v;
    cin >> u >> v;
    counti[u]++;
    counti[v]++;
    counti[LCA(u, v)] -= 2;
  }
  for (int i = 0; i <= n; ++i) {
    visited[i] = 0;
  }
  dfs2(1);
  for (int i = 0; i < n - 1; i++) {
    int u = edges[i].first;
    int v = edges[i].second;
    if (T[u] == v) swap(u, v);
    cout << countsubtree[v] << ' ';
  }
}
