#include <bits/stdc++.h>
using namespace std;
int DEBUGGING = 0;
const int INF = 1000000000;
const int MOD = 1000000007;
const long long LINF = 1e18;
const double PI = 3.1415926535897932;
const double EPS = 1e-7;
long long gcdEx(long long a, long long b, long long *x, long long *y) {
  if (!a) {
    *x = 0;
    *y = 1;
    return b;
  }
  long long x1, y1, gcd = gcdEx(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long modI(long long b, long long m) {
  long long x, y;
  gcdEx(b, m, &x, &y);
  return (x % m + m) % m;
}
long long modD(long long a, long long b) {
  return (modI(b, MOD) * (a % MOD)) % MOD;
}
long long modS(long long a, long long b) {
  return ((a % MOD) - (b % MOD) + MOD) % MOD;
}
long long modP(long long x, long long y) {
  long long r = 1;
  x %= MOD;
  while (y > 0) {
    if (y & 1) {
      r = (r * x) % MOD;
    }
    y = y >> 1;
    x = (x * x) % MOD;
  }
  return r;
}
long long modA(long long a, long long b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}
long long modM(long long a, long long b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> adj[100005];
vector<int> et;
int h[100005], fe[100005];
int vis[100005];
int sm[100005];
int ans[100005];
map<pair<int, int>, int> em;
vector<int> st;
int n, k;
void etdfs(int u = 0, int ht = 0) {
  vis[u] = 1;
  h[u] = ht;
  fe[u] = et.size();
  et.push_back(u);
  for (auto v : adj[u]) {
    if (!vis[v]) {
      etdfs(v, ht + 1);
      et.push_back(u);
    }
  }
}
int ansdfs(int u = 0) {
  vis[u] = 1;
  int pi, cnt, tcnt = 0;
  for (auto v : adj[u]) {
    if (!vis[v]) {
      cnt = ansdfs(v);
      pi = em[{u, v}];
      ans[pi] += cnt;
      tcnt += cnt;
    }
  }
  return tcnt + sm[u];
}
void buildst(int x, int b, int e) {
  if (b == e) {
    st[x] = et[b];
  } else {
    int m = (b + e) >> 1;
    buildst(x << 1, b, m);
    buildst(x << 1 | 1, m + 1, e);
    int l = st[x << 1], r = st[x << 1 | 1];
    st[x] = (h[l] < h[r]) ? l : r;
  }
}
int rangemin(int x, int b, int e, int l, int r) {
  if (b > r || e < l) return -1;
  if (b >= l && e <= r) return st[x];
  int m = (b + e) >> 1;
  int l2 = rangemin(x << 1, b, m, l, r);
  int r2 = rangemin(x << 1 | 1, m + 1, e, l, r);
  if (l2 == -1) return r2;
  if (r2 == -1) return l2;
  return h[l2] < h[r2] ? l2 : r2;
}
int lca(int u, int v) {
  int l = fe[u], r = fe[v];
  if (l > r) swap(l, r);
  return rangemin(1, 0, et.size() - 1, l, r);
}
void solve(int TEST_CASE) {
  int t1, t2;
  cin >> n;
  for (int i = 0; i < (n - 1); ++i) {
    cin >> t1 >> t2;
    t1--;
    t2--;
    adj[t1].push_back(t2);
    adj[t2].push_back(t1);
    em[{t1, t2}] = i;
    em[{t2, t1}] = i;
  }
  memset(vis, 0, sizeof(vis));
  etdfs();
  int l = et.size();
  if (DEBUGGING) {
    for (int i = 0; i < (l); ++i) cout << et[i] << " ";
    cout << "\n";
    for (int i = 0; i < (n); ++i) cout << fe[i] << " ";
    cout << "\n";
  }
  st.resize(4 * l);
  buildst(1, 0, l - 1);
  if (DEBUGGING) {
    for (int i = 0; i < (4 * l); ++i) cout << st[i] << " ";
    cout << "\n";
  }
  cin >> k;
  int f1, f2, an;
  memset(sm, 0, sizeof(sm));
  for (int i = 0; i < (k); ++i) {
    cin >> f1 >> f2;
    f1--;
    f2--;
    an = lca(f1, f2);
    if (DEBUGGING)
      cout << "(" << f1 << "," << f2 << "): lca = " << an << ", "
           << "\n";
    sm[f1]++;
    sm[f2]++;
    sm[an] -= 2;
  }
  if (DEBUGGING) {
    for (int i = 0; i < (n); ++i) cout << sm[i] << " ";
    cout << "\n";
  }
  memset(vis, 0, sizeof(vis));
  ansdfs();
  for (int i = 0; i < (n - 1); ++i) {
    cout << ans[i] << " ";
  }
}
int main(int argc, char *argv[]) {
  if (argc == 2 && argv[1][1] == 'v') DEBUGGING = 1;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin.exceptions(cin.failbit);
  int nTestCases = 1;
  for (int i = 1; i <= (nTestCases); ++i) solve(i);
  return 0;
}
