#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
int n, l;
vector<vector<pair<int, int> > > adj;
int timer;
vector<int> tin, tout, ans, counter, prefixCounter;
vector<vector<int> > up;
void dfs(int v, int w, int p) {
  tin[v] = ++timer;
  up[v][0] = p;
  for (int i = 1; i <= l; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  for (pair<int, int> u : adj[v]) {
    if (u.first != p) dfs(u.first, u.second, v);
  }
  tout[v] = ++timer;
}
bool is_ancestor(int u, int v) {
  return tin[u] <= tin[v] && tout[u] >= tout[v];
}
int lca(int u, int v) {
  if (is_ancestor(u, v)) return u;
  if (is_ancestor(v, u)) return v;
  for (int i = l; i >= 0; --i) {
    if (!is_ancestor(up[u][i], v)) u = up[u][i];
  }
  return up[u][0];
}
void preprocess() {
  cin >> n;
  ans.resize(n - 1, 0);
  adj.resize(n + 1, vector<pair<int, int> >());
  for (int i = 0; i < n - 1; i += 1) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(make_pair(v, i));
    adj[v].push_back(make_pair(u, i));
  }
  tin.resize(n + 1);
  tout.resize(n + 1);
  counter.resize(n + 1, 0);
  prefixCounter.resize(n + 1, 0);
  timer = 0;
  l = ceil(log2(n + 1));
  up.assign(n + 1, vector<int>(l + 1));
  dfs(1, -1, 1);
}
void dfs1(int u, int p) {
  prefixCounter[u] = counter[u];
  for (pair<int, int> v : adj[u]) {
    if (v.first != p) {
      dfs1(v.first, u);
      ans[v.second] = prefixCounter[v.first];
      prefixCounter[u] += prefixCounter[v.first];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  preprocess();
  int k;
  cin >> k;
  while (k--) {
    int a, b;
    cin >> a >> b;
    int parent = lca(a, b);
    counter[a] += 1;
    counter[b] += 1;
    counter[parent] -= 2;
  }
  dfs1(1, 1);
  for (int var : ans) cout << var << " ";
  return 0;
}
