#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const long long INF64 = 9e18;
const long double EPS = 1e-12;
const long double PI = 3.1415926535897932384626433832795028841;
const long long MD = 925262732;
const long long T = 634521;
const int N = 500010;
const int M = 51;
int n, m, up[20][N], tin[N], tout[N], timer = 0, ans[N], f[N];
vector<pair<int, int> > g[N];
vector<int> go, q[N];
bool mark[N], mm[N];
void dfs(int v, int pp = 1) {
  mm[v] = 1;
  tin[v] = timer++;
  up[0][v] = pp;
  for (int i = 1; i < 20; i++) up[i][v] = up[i - 1][up[i - 1][v]];
  for (int i = 0; i < int(int((g[v]).size())); i++)
    if (!mm[g[v][i].first]) dfs(g[v][i].first, v);
  tout[v] = timer++;
}
bool get(int a, int b) { return (tin[a] <= tin[b] && tout[a] >= tin[b]); }
int lca(int a, int b) {
  if (get(a, b)) return a;
  if (get(b, a)) return b;
  for (int i = 19; i >= 0; i--)
    if (!get(up[i][a], b)) a = up[i][a];
  return up[0][a];
}
int dfs_a(int v, int p = 100001) {
  mark[v] = 1;
  int sum = 0;
  for (int i = 0; i < int(int((g[v]).size())); i++)
    if (!mark[g[v][i].first]) sum += dfs_a(g[v][i].first, g[v][i].second);
  for (int i = 0; i < int(int((q[v]).size())); i++) {
    int z = lca(v, q[v][i]);
    if (z != v) {
      sum++;
      f[z]++;
    }
  }
  sum -= f[v];
  ans[p] = sum;
  return sum;
}
int main() {
  cin >> n;
  for (int i = 0; i < int(n - 1); i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    g[first].push_back(make_pair(second, i));
    g[second].push_back(make_pair(first, i));
  }
  dfs(1);
  cin >> m;
  for (int i = 0; i < int(m); i++) {
    int first, second;
    scanf("%d %d", &first, &second);
    q[first].push_back(second);
    q[second].push_back(first);
  }
  dfs_a(1);
  for (int i = 0; i < int(n - 1); i++) printf("%d ", ans[i]);
  return 0;
}
