#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int K = 19;
vector<int> v[N];
vector<pair<int, int> > e;
int anc[N][K], h[N];
int sz[N];
bool flag;
void dfs(int s, int p) {
  if (!flag) {
    h[s] = h[p] + 1;
    anc[s][0] = p;
    for (int i = 1; i < K; i++) anc[s][i] = anc[anc[s][i - 1]][i - 1];
  }
  for (int i = 0; i < v[s].size(); i++) {
    int ii = v[s][i];
    if (ii != p) dfs(ii, s), sz[s] += sz[ii];
  }
}
int LCA(int x, int y) {
  if (h[x] > h[y]) swap(x, y);
  int d = h[y] - h[x];
  for (int i = K - 1; i >= 0; i--)
    if ((1 << i) & d) y = anc[y][i];
  if (x == y) return x;
  for (int i = K - 1; i >= 0; i--)
    if (anc[x][i] != anc[y][i]) x = anc[x][i], y = anc[y][i];
  return anc[x][0];
}
int main() {
  int n, x, y;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    e.push_back({x, y});
  }
  dfs(1, 0);
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    sz[x]++;
    sz[y]++;
    sz[LCA(x, y)] -= 2;
  }
  flag = 1;
  dfs(1, 0);
  for (auto i : e) {
    x = i.first, y = i.second;
    if (h[x] > h[y]) swap(x, y);
    cout << sz[y] << " ";
  }
  return 0;
}
