#include <bits/stdc++.h>
using namespace std;
void Print() { cout << endl; }
template <typename T1, typename... T>
void Print(const T1 &t1, const T &...t) {
  cout << t1 << " ";
  Print(t...);
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
long long gcd(long long a, long long b) {
  while (b) {
    long long r = a % b;
    a = b, b = r;
  }
  return a;
}
tuple<long long, long long, long long> extend_gcd(long long a, long long b) {
  if (b == 0)
    return make_tuple(a, 1, 0);
  else {
    long long g, nx, ny;
    std::tie(g, nx, ny) = extend_gcd(b, a % b);
    return make_tuple(g, ny, nx - (a / b) * ny);
  }
}
long long fastpow(long long a, long long e, long long mod) {
  if (e == 0) return 1;
  if (e == 1) return a % mod;
  long long t = fastpow(a, e / 2, mod);
  t = t * t % mod;
  if (e & 1)
    return t * a % mod;
  else
    return t % mod;
}
const double PI = 3.14159265358979323846;
const int MOD = (int)1e9 + 7;
const int N = 100005, L = 17;
int n;
int he[N], par[N], anc[L][N], p[N], ans[N], vis[N];
vector<pair<int, int> > edges[N];
void dfs(int v, int h = 1) {
  he[v] = h;
  for (auto toidx : edges[v]) {
    int to = toidx.first;
    if (!he[to]) par[to] = v, dfs(to, h + 1);
  }
}
void process() {
  for (int i = 1; i <= n; ++i) anc[0][i] = par[i];
  for (int l = 1; l < L; ++l)
    for (int i = 1; i <= n; ++i)
      if (anc[l - 1][i] != -1)
        anc[l][i] = anc[l - 1][anc[l - 1][i]];
      else
        anc[l][i] = -1;
}
int lca(int u, int v) {
  if (he[u] < he[v]) swap(u, v);
  for (int j = L - 1; j >= 0; --j)
    if (he[u] - (1 << j) >= he[v]) u = anc[j][u];
  if (u == v) return u;
  for (int j = L - 1; j >= 0; --j) {
    if (anc[j][u] != -1 && anc[j][u] != anc[j][v]) u = anc[j][u], v = anc[j][v];
  }
  return anc[0][u];
}
int dfs2(int v = 1) {
  vis[v] = true;
  int s = 0;
  for (auto toidx : edges[v]) {
    int to = toidx.first, idx = toidx.second;
    if (!vis[to]) {
      int h = dfs2(to);
      s += h;
      ans[idx] += h;
    }
  }
  return s + p[v];
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back((make_pair((b), (i))));
    edges[b].push_back((make_pair((a), (i))));
  }
  par[1] = -1;
  dfs(1);
  process();
  int k;
  cin >> k;
  while (k--) {
    int a, b;
    cin >> a >> b;
    if (a == b) continue;
    int l = lca(a, b);
    if (l == a) {
      --p[a];
      ++p[b];
    } else if (l == b) {
      --p[b];
      ++p[a];
    } else {
      ++p[a];
      ++p[b];
      p[l] -= 2;
    }
  }
  dfs2();
  for (int i = 0; i < n - 1; ++i) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}
