#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long mod) {
  long long c = 1;
  while (b > 0) {
    if (b % 2) c *= a, c %= mod;
    b /= 2;
    a *= a;
    a %= mod;
  }
  return c;
}
struct dty {
  long long v, i;
};
vector<long long> dfs_path;
vector<long long> lev_path;
vector<long long> graph[100005];
unordered_map<long long, long long> vis;
unordered_map<long long, long long> h;
unordered_map<long long, long long> lev;
unordered_map<long long, long long> mp;
unordered_map<long long, long long> parent;
unordered_map<long long, unordered_map<long long, long long>> fool;
unordered_map<long long, unordered_map<long long, long long>> ans;
dty tree[1000005];
long long cp = 0;
vector<dty> edges;
void make_tree(long long low, long long high, long long pos) {
  if (low == high) {
    tree[pos].v = lev_path[low];
    tree[pos].i = low;
    return;
  }
  long long mid = (low + high) / 2;
  make_tree(low, mid, 2 * pos + 1);
  make_tree(mid + 1, high, 2 * pos + 2);
  if (tree[2 * pos + 1].v > tree[2 * pos + 2].v)
    tree[pos] = tree[2 * pos + 2];
  else
    tree[pos] = tree[2 * pos + 1];
  return;
}
dty rangeminquery(long long qlow, long long qhigh, long long low,
                  long long high, long long pos) {
  if ((qlow <= low) && (qhigh >= high)) {
    return tree[pos];
  }
  if ((qlow > high) || (qhigh < low)) {
    return {1000000007, 1000000007};
  }
  long long mid = (high + low) / 2;
  dty t1 = rangeminquery(qlow, qhigh, low, mid, 2 * pos + 1);
  dty t2 = rangeminquery(qlow, qhigh, mid + 1, high, 2 * pos + 2);
  if (t1.v < t2.v)
    return t1;
  else
    return t2;
}
void dfs(long long u) {
  vis[u] = 1;
  for (long long i = 0; i < graph[u].size(); i++) {
    long long v = graph[u][i];
    if (!vis[v]) {
      parent[v] = u;
      h[v] = cp++;
      dfs_path.push_back(v);
      lev[v] = lev[u] + 1;
      lev_path.push_back(lev[v]);
      dfs(v);
      dfs_path.push_back(u);
      lev_path.push_back(lev[u]);
      cp++;
    }
  }
}
void fun(long long u, long long p) {
  ans[u][p] = fool[u][p];
  for (long long i = 0; i < graph[u].size(); i++) {
    long long v = graph[u][i];
    if (v != p) {
      fun(v, u);
      ans[u][p] += ans[v][u];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
    dty temp;
    temp.i = u;
    temp.v = v;
    edges.push_back(temp);
  }
  dfs_path.push_back(1);
  lev_path.push_back(1);
  lev[1] = 1;
  h[1] = cp++;
  parent[1] = 0;
  dfs(1);
  make_tree(0, lev_path.size() - 1, 0);
  long long q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    if (h[a] > h[b]) swap(a, b);
    dty w = rangeminquery(h[a], h[b], 0, lev_path.size() - 1, 0);
    long long par = dfs_path[w.i];
    fool[a][parent[a]]++;
    fool[parent[a]][a]++;
    fool[parent[b]][b]++;
    fool[b][parent[b]]++;
    fool[par][parent[par]] -= 2;
    fool[parent[par]][par] -= 2;
  }
  fun(1, 0);
  for (auto i : edges) cout << max(ans[i.i][i.v], ans[i.v][i.i]) << " ";
}
