#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
void clock_out() {
  cerr << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
}
void fileio() {
  freopen("/home/dwai/Desktop/cp/input.txt", "r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}
void ofileio() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
int IT_MAX = 1 << 20;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
long long n, lg;
vector<long long> g[100100];
long long baseArray[100100], ptr;
long long chainNo, chainHead[100100], chainInd[100100], posInBase[100100];
long long lev[100100], subsize[100100];
long long st[6 * 100100], lazy[6 * 100100];
long long dp[100100][20];
void build_tree(long long cur, long long s, long long e) {
  if (s == e) {
    st[cur] = baseArray[s];
    return;
  }
  long long c1 = cur << 1, c2 = c1 | 1, m = (s + e) >> 1;
  build_tree(c1, s, m);
  build_tree(c2, m + 1, e);
  st[cur] = st[c1] + st[c2];
}
void update_tree(long long cur, long long s, long long e, long long l,
                 long long r, long long x = 1) {
  if (s > r || e < l) return;
  if (lazy[cur] != 0) {
    st[cur] += (e - s + 1) * lazy[cur];
    if (s != e) {
      lazy[2 * cur] += lazy[cur];
      lazy[2 * cur + 1] += lazy[cur];
    }
    lazy[cur] = 0;
  }
  if (s >= l && e <= r) {
    st[cur] += (e - s + 1) * x;
    if (s != e) {
      lazy[2 * cur] += x;
      lazy[2 * cur + 1] += x;
    }
    return;
  }
  long long c1 = cur << 1, c2 = c1 | 1, m = (s + e) >> 1;
  update_tree(c1, s, m, l, r);
  update_tree(c2, m + 1, e, l, r);
  st[cur] = st[c1] + st[c2];
}
long long query_tree(long long cur, long long s, long long e, long long l,
                     long long r) {
  if (s > r || e < l) {
    return 0;
  }
  if (lazy[cur] != 0) {
    st[cur] += (e - s + 1) * lazy[cur];
    if (s != e) {
      lazy[2 * cur] += lazy[cur];
      lazy[2 * cur + 1] += lazy[cur];
    }
    lazy[cur] = 0;
  }
  if (s >= l && e <= r) {
    return st[cur];
  }
  long long c1 = cur << 1, c2 = c1 | 1, m = (s + e) >> 1;
  return query_tree(c1, s, m, l, r) + query_tree(c2, m + 1, e, l, r);
}
long long query_up(long long u, long long v) {
  long long uchain, vchain = chainInd[v], ans = 0;
  while (1) {
    uchain = chainInd[u];
    if (uchain == vchain) {
      if (u == v) break;
      ans += query_tree(1, 0, ptr - 1, posInBase[v] + 1, posInBase[u]);
      break;
    }
    ans +=
        query_tree(1, 0, ptr - 1, posInBase[chainHead[uchain]], posInBase[u]);
    u = chainHead[uchain];
    u = dp[u][0];
  }
  return ans;
}
void update_up(long long u, long long v) {
  long long uchain, vchain = chainInd[v];
  while (1) {
    uchain = chainInd[u];
    if (uchain == vchain) {
      if (u == v) break;
      update_tree(1, 0, ptr - 1, posInBase[v] + 1, posInBase[u]);
      break;
    }
    update_tree(1, 0, ptr - 1, posInBase[chainHead[uchain]], posInBase[u]);
    u = chainHead[uchain];
    u = dp[u][0];
  }
}
long long lca(long long u, long long v) {
  if (lev[u] < lev[v]) swap(u, v);
  long long i;
  for (i = lg; i >= 0; i--) {
    if (lev[u] - (1 << i) >= lev[v]) {
      u = dp[u][i];
    }
  }
  if (u == v) return u;
  for (i = lg; i >= 0; i--) {
    if (dp[v][i] != dp[u][i]) {
      u = dp[u][i];
      v = dp[v][i];
    }
  }
  return dp[u][0];
}
long long query(long long u, long long v) {
  long long __lca = lca(u, v);
  return query_up(u, __lca) + query_up(v, __lca);
}
void update(long long u, long long v) {
  long long __lca = lca(u, v);
  update_up(u, __lca);
  update_up(v, __lca);
}
void hld(long long cur, long long prev) {
  if (chainHead[chainNo] == -1) {
    chainHead[chainNo] = cur;
  }
  chainInd[cur] = chainNo;
  posInBase[cur] = ptr;
  baseArray[ptr++] = 0;
  long long sc = -1, i;
  for (i = 0; i < (long long)g[cur].size(); i++) {
    if (g[cur][i] == prev) continue;
    if (subsize[g[cur][i]] >= subsize[cur] / 2) {
      sc = g[cur][i];
      break;
    }
  }
  if (sc != -1) {
    hld(sc, cur);
  }
  for (i = 0; i < (long long)g[cur].size(); i++) {
    if (sc != g[cur][i] && g[cur][i] != prev) {
      chainNo++;
      hld(g[cur][i], cur);
    }
  }
}
void dfs(long long u, long long p) {
  dp[u][0] = p;
  subsize[u] = 1;
  long long i;
  for (i = 1; i <= lg; i++) {
    if (dp[u][i - 1] != -1) {
      dp[u][i] = dp[dp[u][i - 1]][i - 1];
    }
  }
  for (i = 0; i < (long long)g[u].size(); i++) {
    if (g[u][i] == p) continue;
    lev[g[u][i]] = lev[u] + 1;
    dfs(g[u][i], u);
    subsize[u] += subsize[g[u][i]];
  }
}
void solve() {
  cin >> n;
  lg = ceil(log2(n));
  long long i;
  for (i = 0; i <= n - 1; i++) {
    chainHead[i] = -1;
  }
  vector<pair<long long, long long> > v;
  for (i = 0; i < n - 1; i++) {
    long long l, r;
    cin >> l >> r;
    l--;
    r--;
    g[l].emplace_back(r);
    g[r].emplace_back(l);
    v.emplace_back(make_pair(l, r));
  }
  dfs(0, -1);
  hld(0, -1);
  build_tree(1, 0, ptr - 1);
  long long k;
  cin >> k;
  while (k--) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    update(a, b);
  }
  for (pair<long long, long long> p : v) {
    cout << query(p.first, p.second) << " ";
  }
}
int main() {
  42;
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
