#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
vector<int> e[N];
pair<int, int> E[N];
long long f[N];
int nin[N], nou[N];
int Nin, Nou;
int cha[N][50];
void DFS(int first, int p) {
  nin[first] = ++Nin;
  for (int i(1); i <= 30; i++) cha[first][i] = cha[cha[first][i - 1]][i - 1];
  for (auto& i : e[first])
    if (i != p) {
      cha[i][0] = first;
      DFS(i, first);
    }
  nou[first] = ++Nou;
}
bool father(int first, int second) {
  return nin[first] <= nin[second] && nou[first] >= nou[second];
}
int LCA(int first, int second) {
  if (father(first, second)) return first;
  if (father(second, first)) return second;
  for (int i(30); 0 <= i; i--)
    if (!father(cha[first][i], second)) first = cha[first][i];
  return cha[first][0];
}
void CAL(int first, int p) {
  for (auto& i : e[first])
    if (i != p) {
      CAL(i, first);
      f[first] += f[i];
    }
}
int main() {
  n = ({
    long long first = 0;
    int n = 0, c = getchar();
    for (; !isdigit(c); c = getchar()) n = c == '-';
    for (; isdigit(c); c = getchar()) first = first * 10 + c - '0';
    n ? -first : first;
  });
  for (int i(1); i <= n - 1; i++) {
    int first = ({
      long long first = 0;
      int n = 0, c = getchar();
      for (; !isdigit(c); c = getchar()) n = c == '-';
      for (; isdigit(c); c = getchar()) first = first * 10 + c - '0';
      n ? -first : first;
    }),
        second = ({
          long long first = 0;
          int n = 0, c = getchar();
          for (; !isdigit(c); c = getchar()) n = c == '-';
          for (; isdigit(c); c = getchar()) first = first * 10 + c - '0';
          n ? -first : first;
        });
    E[i] = {first, second};
    e[first].push_back(second);
    e[second].push_back(first);
  }
  cha[1][0] = 1;
  DFS(1, 1);
  int q = ({
    long long first = 0;
    int n = 0, c = getchar();
    for (; !isdigit(c); c = getchar()) n = c == '-';
    for (; isdigit(c); c = getchar()) first = first * 10 + c - '0';
    n ? -first : first;
  });
  for (int i(1); i <= q; i++) {
    int first = ({
      long long first = 0;
      int n = 0, c = getchar();
      for (; !isdigit(c); c = getchar()) n = c == '-';
      for (; isdigit(c); c = getchar()) first = first * 10 + c - '0';
      n ? -first : first;
    }),
        second = ({
          long long first = 0;
          int n = 0, c = getchar();
          for (; !isdigit(c); c = getchar()) n = c == '-';
          for (; isdigit(c); c = getchar()) first = first * 10 + c - '0';
          n ? -first : first;
        });
    int lca = LCA(first, second);
    f[first]++;
    f[second]++;
    f[lca] -= 2;
  }
  CAL(1, 1);
  for (int i(1); i <= n - 1; i++) {
    int first = E[i].first, second = E[i].second;
    if (cha[second][0] == first) swap(first, second);
    cout << f[first] << " ";
  }
}
