#include <bits/stdc++.h>
using namespace std;
const long long maxn = 100000 + 2;
long long n, x, y, k, h[maxn], par[maxn][32], vol[maxn];
vector<long long> adj[maxn];
pair<long long, long long> p[maxn];
bool mark[maxn];
void dfs(int x) {
  mark[x] = 1;
  for (int i = 0; i < adj[x].size(); i++) {
    int next = adj[x][i];
    if (mark[next]) continue;
    par[next][0] = x;
    h[next] = h[x] + 1;
    for (int i = 1; i <= 30; i++) par[next][i] = par[par[next][i - 1]][i - 1];
    dfs(next);
  }
}
void LCA(int x, int y) {
  vol[x]++;
  vol[y]++;
  if (h[x] < h[y]) swap(x, y);
  int d = h[x] - h[y];
  for (int i = 0; i <= 30; i++)
    if ((d >> i) % 2) x = par[x][i];
  if (y == x) {
    vol[x] -= 2;
    return;
  }
  for (int i = 30; i >= 0; i--)
    if (par[x][i] != par[y][i]) {
      x = par[x][i];
      y = par[y][i];
    }
  vol[par[x][0]] -= 2;
}
void dfs1(int x) {
  mark[x] = 1;
  for (int i = 0; i < adj[x].size(); i++)
    if (!mark[adj[x][i]]) {
      dfs1(adj[x][i]);
      vol[x] += vol[adj[x][i]];
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    p[i] = make_pair(x, y);
  }
  h[1] = 1;
  dfs(1);
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    LCA(x, y);
  }
  for (int i = 1; i <= n; i++) mark[i] = 0;
  dfs1(1);
  for (int i = 1; i < n; i++) {
    if (par[p[i].first][0] == p[i].second)
      cout << vol[p[i].first] << " ";
    else
      cout << vol[p[i].second] << " ";
  }
  return 0;
}
