#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int l[MAX], lg[MAX], p[MAX][20];
vector<int> g[MAX];
int n, k;
int mk[MAX];
vector<int> X[MAX];
queue<pair<int, int> > cola1;
void dfs_lca(int u, int lev = 1, int pt = 0) {
  l[u] = lev;
  p[u][0] = pt;
  for (int v : g[u])
    if (v != pt) dfs_lca(v, lev + 1, u);
}
void init_lca() {
  dfs_lca(1);
  for (int i = 1; i <= n; i++) lg[i] = log2(i);
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i <= n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
}
int lca(int a, int b) {
  if (l[a] < l[b]) swap(a, b);
  for (int i = lg[l[a]]; i >= 0; i--)
    if (l[a] - (1 << i) >= l[b]) a = p[a][i];
  if (a == b) return a;
  for (int i = lg[l[a]]; i >= 0; i--)
    if (p[a][i] && p[a][i] != p[b][i]) a = p[a][i], b = p[b][i];
  return p[a][0];
}
queue<pair<int, int> > cola;
int B[MAX];
void bfs() {
  while (!cola.empty()) {
    int nx = cola.front().first;
    int cant = cola.front().second;
    cola.pop();
    if (B[nx] == (int)g[nx].size() - 1) {
      for (int i = 0; i < (int)g[nx].size(); i++) {
        if (l[nx] > l[g[nx][i]]) {
          B[g[nx][i]]++;
          mk[g[nx][i]] += cant;
          cola.push(make_pair(g[nx][i], mk[g[nx][i]]));
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
    cola1.push(make_pair(a, b));
  }
  init_lca();
  cin >> k;
  for (int i = 1; i <= k; i++) {
    int a, b;
    cin >> a >> b;
    int u = lca(a, b);
    mk[a]++;
    mk[b]++;
    mk[u] -= 2;
  }
  int ma = 0;
  for (int i = 1; i <= n; i++) {
    ma = max(l[i], ma);
    X[l[i]].push_back(i);
  }
  for (int i = ma; i >= 1; i--) {
    for (int j : X[i]) {
      mk[p[j][0]] += mk[j];
    }
  }
  while (!cola1.empty()) {
    int nx = cola1.front().first;
    int ny = cola1.front().second;
    cola1.pop();
    if (l[nx] > l[ny])
      cout << mk[nx] << " ";
    else
      cout << mk[ny] << " ";
  }
  cout << "\n";
  return 0;
}
