#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
pair<int, int> rr[100009];
int lvl[100009], P[100009][18 + 9], a, arr[100009];
vector<int> adj[100009];
void dfs(int nd, int pr) {
  lvl[nd] = lvl[pr] + 1;
  P[nd][0] = pr;
  for (typeof((adj[nd]).begin()) v = (adj[nd]).begin(); v != (adj[nd]).end();
       v++)
    if (*v != pr) dfs(*v, nd);
}
void build() {
  for (int j = 1; j < 18; j++)
    for (int i = 1; i <= a; i++)
      if (P[i][j - 1] != -1) P[i][j] = P[P[i][j - 1]][j - 1];
}
int LCA(int x, int y) {
  if (lvl[x] < lvl[y]) swap(x, y);
  for (int i = 18; i >= 0; i--)
    if (lvl[x] - (1 << i) >= lvl[y]) x = P[x][i];
  if (x == y) return x;
  for (int i = 18; i >= 0; i--)
    if (P[x][i] != -1 and P[x][i] != P[y][i]) x = P[x][i], y = P[y][i];
  return P[x][0];
}
void dfs1(int nd, int pr) {
  for (typeof((adj[nd]).begin()) v = (adj[nd]).begin(); v != (adj[nd]).end();
       v++)
    if (*v != pr) dfs1(*v, nd);
  arr[P[nd][0]] += arr[nd];
}
int main() {
  memset(P, -1, sizeof(P));
  cin >> a;
  for (int i = 0; i < a - 1; i++) {
    int u, v;
    cin >> u >> v;
    rr[i] = {u, v};
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0);
  build();
  int k;
  cin >> k;
  while (k--) {
    int u, v;
    cin >> u >> v;
    int z = LCA(u, v);
    arr[u]++;
    arr[v]++;
    arr[z] -= 2;
  }
  dfs1(1, 0);
  for (int i = 0; i < a - 1; i++) {
    int u = rr[i].first, v = rr[i].second;
    if (P[u][0] == v)
      cout << arr[u] << " ";
    else
      cout << arr[v] << " ";
  }
  cout << endl;
  return 0;
}
