#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
const double PI = acos(-1.0);
const int INF = 1e9;
const long long BIGINF = 4e18;
const long long MOD = 998244353;
const double EPS = 1e-6;
mt19937 rng(time(0));
uniform_int_distribution<int> uid(-1000000000, 1000000000);
long long dx[100009];
vector<int> g[100009];
int d[100009], f[100009], p[500009];
int sp[120][500009];
vector<int> v;
int n, m;
map<pair<int, int>, int> w;
vector<long long> res;
void dfs(int x, int pr = -1, int k = 0) {
  d[x] = k;
  v.push_back(x);
  for (auto& i : g[x]) {
    if (pr != i) {
      dfs(i, x, k + 1);
      v.push_back(x);
    }
  }
}
void rec(int x, int p = -1) {
  for (auto& i : g[x]) {
    if (p == i) continue;
    rec(i, x);
    dx[x] += dx[i];
  }
  if (p != -1) res[w[{min(x, p), max(x, p)}]] = dx[x];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, a, b;
  cin >> n;
  res.assign(n - 1, 0);
  for (int i = 0; i < n - 1; ++i) {
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
    w[{min(a, b), max(a, b)}] = i;
  }
  dfs(0);
  fill(f, f + n + 1, -1);
  for (int i = 0; i < v.size(); ++i) {
    if (f[v[i]] == -1) f[v[i]] = i;
  }
  for (int i = 2; i <= v.size(); ++i) p[i] = p[i / 2] + 1;
  for (int i = 0; i < v.size(); ++i) {
    sp[0][i] = v[i];
  }
  for (int i = 1; (1 << i) <= v.size(); ++i) {
    for (int j = 0; j + (1 << i) <= v.size(); ++j) {
      sp[i][j] = (d[sp[i - 1][j]] < d[sp[i - 1][j + (1 << (i - 1))]]
                      ? sp[i - 1][j]
                      : sp[i - 1][j + (1 << (i - 1))]);
    }
  }
  int q;
  cin >> q;
  while (q--) {
    cin >> a >> b;
    --a, --b;
    int vv = f[a], uu = f[b];
    if (vv < uu) swap(uu, vv);
    int lca = (d[sp[p[vv - uu + 1]][uu]] <
                       d[sp[p[vv - uu + 1]][vv - (1 << p[vv - uu + 1]) + 1]]
                   ? sp[p[vv - uu + 1]][uu]
                   : sp[p[vv - uu + 1]][vv - (1 << p[vv - uu + 1]) + 1]);
    dx[a] += 1;
    dx[b] += 1;
    dx[lca] -= 2;
  }
  rec(0);
  for (auto& i : res) cout << i << " ";
  cout << '\n';
  return 0;
}
