#include <bits/stdc++.h>
using namespace std;
string alpha = "abcdefghijklmnopqrstuvwxyz";
const long long mod = 1e9 + 7;
const long long inf = 2e18 + 5;
const long long nax = 101010;
vector<vector<long long>> g;
long long dp[nax][20];
bool visited[nax];
long long level[nax];
void dfsp(long long u, long long i = 0) {
  visited[u] = true;
  level[u] = i;
  for (auto v : g[u]) {
    if (!visited[v]) {
      dp[v][0] = u;
      dfsp(v, i + 1);
    }
  }
  visited[u] = false;
}
long long walk(long long u, long long x) {
  for (long long i = (0); i < (20); i++) {
    if ((x & (1 << i))) {
      u = dp[u][i];
    }
  }
  return u;
}
long long lca(long long u, long long v) {
  if (level[u] < level[v]) {
    v = walk(v, level[v] - level[u]);
  } else {
    u = walk(u, level[u] - level[v]);
  }
  assert(level[u] == level[v]);
  if (u == v) return u;
  for (long long i = (19); i > (-1); --i) {
    long long l1 = walk(u, (1 << i));
    long long l2 = walk(v, (1 << i));
    if (l1 == l2) continue;
    u = l1;
    v = l2;
  }
  return walk(u, 1);
}
map<pair<long long, long long>, long long> res;
long long w[nax];
void dfs(long long u) {
  visited[u] = true;
  for (auto v : g[u]) {
    if (!visited[v]) {
      dfs(v);
      res[{u, v}] += w[v];
      w[u] += w[v];
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  g = vector<vector<long long>>(n + 1);
  vector<pair<long long, long long>> E;
  for (long long i = (0); i < (n - 1); i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    E.push_back({u, v});
  }
  dp[1][0] = 1;
  dfsp(1);
  for (long long i = (1); i < (20); i++) {
    for (long long u = (1); u < (n + 1); u++) {
      dp[u][i] = dp[dp[u][i - 1]][i - 1];
    }
  }
  long long k;
  cin >> k;
  for (long long i = (0); i < (k); i++) {
    long long a, b;
    cin >> a >> b;
    w[a]++;
    w[b]++;
    w[lca(a, b)] -= 2;
  }
  dfs(1);
  for (auto p : E) {
    long long a = p.first;
    long long b = p.second;
    cout << res[p] + res[{b, a}] << " ";
  }
  return 0;
}
