#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const int MOD = 1e9 + 7;
const long long oo = 1e9 + 7;
long long GCD(long long a, long long b) { return !b ? a : GCD(b, a % b); }
struct node {
  int idx, dpth;
  node(int tidx, int tdpth) {
    idx = tidx;
    dpth = tdpth;
  }
  node() { idx = dpth = 0; }
};
const int mx = 1e5 + 1;
int n, idx[mx], val[mx];
vector<int> adj[mx];
vector<node> eulerTour;
node dp[18][mx << 1];
bool vis[mx];
void dfs(int u, int lvl) {
  vis[u] = 1;
  if (idx[u] == -1) idx[u] = (int)eulerTour.size();
  for (int i = 0; i < (int)adj[u].size(); i++)
    if (!vis[adj[u][i]]) {
      eulerTour.push_back(node(u, lvl));
      dfs(adj[u][i], lvl + 1);
      eulerTour.push_back(node(adj[u][i], lvl + 1));
    }
}
int lca(int a, int b) {
  a = idx[a];
  b = idx[b];
  if (a > b) swap(a, b);
  int k = b - a + 1, pw = 0;
  while (k) ++pw, k >>= 1;
  if ((1 << pw) > b - a + 1) --pw;
  if (dp[pw][a].dpth < dp[pw][b - (1 << pw) + 1].dpth) return dp[pw][a].idx;
  return dp[pw][b - (1 << pw) + 1].idx;
}
void preProcess() {
  for (int i = 0; i < (int)eulerTour.size(); i++) dp[0][i] = eulerTour[i];
  for (int i = 1; i < 18; i++) {
    for (int j = 0; j + (1 << (i - 1)) < (int)eulerTour.size(); j++) {
      if ((dp[i - 1][j].dpth > dp[i - 1][j + (1 << (i - 1))].dpth))
        dp[i][j] = dp[i - 1][j + (1 << (i - 1))];
      else
        dp[i][j] = dp[i - 1][j];
    }
  }
}
map<pair<int, int>, int> cst;
void calc(int u, int p) {
  vis[u] = 1;
  for (int i = 0; i < (int)adj[u].size(); i++)
    if (!vis[adj[u][i]]) {
      calc(adj[u][i], u);
    }
  if (u != p)
    val[p] += val[u], cst[make_pair(u, p)] = cst[make_pair(p, u)] = val[u];
}
int main() {
  int u, v;
  cin >> n;
  vector<pair<int, int> > in;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    in.push_back(make_pair(u, v));
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  memset(idx, -1, sizeof idx);
  dfs(1, 0);
  eulerTour.push_back(node(1, 0));
  preProcess();
  int k, a, b;
  cin >> k;
  while (k-- && scanf("%d%d", &a, &b)) {
    ++val[a], ++val[b], val[lca(a, b)] -= 2;
  }
  memset(vis, 0, sizeof vis);
  calc(1, 1);
  for (int i = 0; i < n - 1; i++) printf("%d ", cst[in[i]]);
  puts("");
  return 0;
}
