#include <bits/stdc++.h>
using namespace std;
template <class T, class first>
inline bool getbit(T a, first i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class first>
inline T setbit(T a, first i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class first>
inline T resetbit(T a, first i) {
  T t = 1;
  return (a & (~(t << i)));
}
template <class T, class first>
inline T togglebit(T a, first i) {
  T t = 1;
  return (a ^ (t << i));
}
template <typename T>
T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
T BIGMOD(T b, T p, T m) {
  if (p == 0)
    return 1;
  else if (!(p & 1))
    return (Bigmod(b, p / 2, m) * Bigmod(b, p / 2, m)) % m;
  else
    return ((b % m) * Bigmod(b, p - 1, m)) % m;
}
template <typename T>
T Bigmod(T base, T power, T mod) {
  T ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % mod;
    base = (base * base) % mod;
    power >>= 1;
  }
  return ret;
}
template <typename T>
T ModInverse(T number, T mod) {
  return Bigmod(number, mod - 2, mod);
}
template <typename T>
T GCD(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <typename T>
T EUCLIDE(T a, T b, T &x, T &y) {
  if (a < 0) {
    T d = euclide(-a, b, x, y);
    x = -x;
    return d;
  }
  if (b < 0) {
    T d = euclide(a, -b, x, y);
    y = -y;
    return d;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    T d = euclide(b, a % b, x, y);
    T t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
  }
}
double DEG(double x) { return (180.0 * x) / ((2.0 * acos(0.0))); }
double RAD(double x) { return (x * (double)(2.0 * acos(0.0))) / (180.0); }
template <typename T>
T DIS(T x1, T y1, T x2, T y2) {
  return sqrt((double)((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
}
template <typename T>
T ANGLE(T x1, T y1, T x2, T y2) {
  return atan(double(y1 - y2) / double(x1 - x2));
}
template <typename T>
long long isLeft(T a, T b, T c) {
  return (c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y);
}
void P_ARR(int *ar, int a, int b) {
  if (a > b) swap(a, b);
  if (a <= b) cout << ar[a];
  for (int i = a + 1; i <= b; i++) cout << " " << ar[i];
  cout << endl;
}
vector<int> adj[300007];
int par[300007];
int lev[300007];
bool vis[300007];
int dp[300007][25];
int ar[300007];
int arrived[300007], departure[300007];
int id[300007];
int n;
int ans[300007];
int clk;
int cnt[300007];
void BFS() {
  queue<int> q;
  q.push(1);
  lev[1] = 0;
  vis[1] = 1;
  par[1] = -1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i += 2) {
      int v = adj[u][i];
      int c = adj[u][i + 1];
      if (!vis[v]) {
        vis[v] = true;
        lev[v] = lev[u] + 1;
        par[v] = u;
        id[v] = c;
        q.push(v);
      }
    }
  }
}
void process(int n) {
  memset(dp, -1, sizeof dp);
  par[1] = -1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = par[i];
  }
  for (int j = 1; (1 << j) < n; j++) {
    for (int i = 1; i <= n; i++) {
      if (dp[i][j - 1] != -1) {
        dp[i][j] = dp[dp[i][j - 1]][j - 1];
      }
    }
  }
}
int lca(int x, int y) {
  if (lev[x] < lev[y]) swap(x, y);
  int lev_x;
  for (lev_x = 1; (1 << lev_x) <= lev[x]; lev_x++)
    ;
  lev_x--;
  for (int i = lev_x; i >= 0; i--) {
    if (lev[x] - (1 << i) >= lev[y]) {
      x = dp[x][i];
    }
  }
  if (x == y) return x;
  for (int i = lev_x; i >= 0; i--) {
    if (dp[x][i] != -1 && dp[x][i] != dp[y][i]) {
      x = dp[x][i];
      y = dp[y][i];
    }
  }
  return par[x];
}
int solve(int u) {
  int sum = cnt[u];
  vis[u] = true;
  for (int i = 0; i < adj[u].size(); i += 2) {
    int v = adj[u][i];
    int c = adj[u][i];
    if (!vis[v]) {
      sum += solve(v);
    }
  }
  ans[id[u]] = sum;
  return sum;
}
int main() {
  scanf("%d", &n);
  int x, y, c;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d", &x, &y);
    c = i;
    adj[x].push_back(y);
    adj[x].push_back(i);
    adj[y].push_back(x);
    adj[y].push_back(i);
  }
  par[1] = -1;
  lev[1] = 0;
  vis[1] = true;
  BFS();
  process(n);
  int q;
  scanf("%d", &q);
  for (int j = 1; j <= q; j++) {
    scanf("%d%d", &x, &y);
    int l = lca(x, y);
    cnt[x]++;
    cnt[y]++;
    cnt[l] -= 2;
  }
  memset(vis, 0, sizeof vis);
  solve(1);
  for (int i = 1; i <= n - 1; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
