#include <bits/stdc++.h>
using namespace std;
int n, k, l;
int odw[100007], odw2[100007];
vector<pair<int, int> > road[100007];
int gle[100007];
int ancestor[100007][22];
vector<pair<int, int> > order[100007];
vector<int> V[100007];
int VP[100007];
int VD[100007];
void dfs(int v, int g) {
  odw[v] = 1;
  gle[v] = g;
  g++;
  for (int i = 0; i < V[v].size(); i++)
    if (!odw[V[v][i]]) {
      ancestor[V[v][i]][0] = v;
      dfs(V[v][i], g);
    }
}
int dfs2(int v) {
  int c;
  odw2[v] = 1;
  for (int i = 0; i < V[v].size(); i++)
    if (!odw2[V[v][i]]) {
      c = dfs2(V[v][i]);
      VP[v] += c;
      road[v].push_back({V[v][i], c}), road[V[v][i]].push_back({v, c});
    }
  return VP[v];
}
void lca(int a, int b) {
  if (gle[b] < gle[a]) swap(a, b);
  int A = a, B = b;
  for (int p = 20; p >= 0; p--)
    if (gle[ancestor[b][p]] >= gle[a]) b = ancestor[b][p];
  if (b == a) {
    VP[b]--;
    VP[B]++;
    return;
  } else
    for (int p = 20; p >= 0; p--)
      if (ancestor[a][p] != ancestor[b][p]) {
        a = ancestor[a][p];
        b = ancestor[b][p];
      }
  VP[ancestor[a][0]] -= 2;
  VP[A]++;
  VP[B]++;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    order[i].push_back({a, b});
    V[a].push_back(b);
    V[b].push_back(a);
  }
  dfs(1, 0);
  ancestor[1][0] = 1;
  for (int p = 1; p <= 20; p++)
    for (int i = 1; i <= n; i++)
      ancestor[i][p] = ancestor[ancestor[i][p - 1]][p - 1];
  cin >> k;
  for (int i = 0; i < k; i++) {
    int A, B;
    cin >> A >> B;
    lca(A, B);
  }
  dfs2(1);
  for (int z = 1; z < n; z++)
    for (int i = 0; i < road[order[z][0].first].size(); i++)
      if (road[order[z][0].first][i].first == order[z][0].second) {
        cout << road[order[z][0].first][i].second << "\n";
        break;
      }
}
