#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long M = (long long)1e9 + 7;
int Int() {
  int x;
  scanf("%d", &x);
  return x;
}
long long Long() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
void Char(char* ch) { scanf("%s", ch); }
template <typename t>
t abs(t a) {
  if (a >= 0) return a;
  return -a;
}
template <typename t>
t Range(vector<t> v, t x) {
  auto u = equal_range(v.begin(), v.end(), x);
  return u.second - u.first;
}
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " ";
  err(++it, args...);
}
vector<int> g[N];
map<pair<int, int>, int> id;
int sz[N], dep[N], par[N][21], freq[N], res[N];
void dfs(int s, int p = -1) {
  par[s][0] = p;
  dep[s] = 1 + dep[p];
  sz[s] = 1;
  for (int i = 1; i <= 20; i++) {
    par[s][i] = par[par[s][i - 1]][i - 1];
  }
  for (auto u : g[s]) {
    if (u == p) continue;
    dfs(u, s);
    sz[s] += sz[u];
  }
}
int GetLCA(int a, int b) {
  if (dep[a] < dep[b]) swap(a, b);
  int d = dep[a] - dep[b];
  for (int i = 20; i >= 0; i--) {
    if (d & (1 << i)) {
      a = par[a][i];
    }
  }
  if (a == b) return a;
  for (int i = 20; i >= 0; i--) {
    if (par[a][i] != par[b][i]) {
      a = par[a][i];
      b = par[b][i];
    }
  }
  return par[a][0];
}
void Find(int s, int p = -1) {
  int ans = 0;
  for (auto u : g[s]) {
    if (u == p) continue;
    Find(u, s);
    res[id[{s, u}]] = freq[u];
    ans += freq[u];
  }
  freq[s] += ans;
}
int main() {
  int n = Int();
  for (int i = 1; i < n; i++) {
    int l = Int(), r = Int();
    g[l].push_back(r);
    g[r].push_back(l);
    id[{l, r}] = id[{r, l}] = i;
  }
  dfs(1);
  int q = Int();
  while (q--) {
    int a = Int(), b = Int();
    int LCA = GetLCA(a, b);
    freq[a]++, freq[b]++;
    freq[LCA] -= 2;
  }
  Find(1);
  for (int i = 1; i < n; i++) {
    printf("%d ", res[i]);
  }
  return 0;
}
