#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
const int mod = (int)1e9 + 7;
const long long INF64 = 3e18;
void smxl(long long &a, long long b) {
  if (a < b) a = b;
}
void smnl(long long &a, long long b) {
  if (a > b) a = b;
}
void adsl(long long &a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
}
void misl(long long &a, long long b) {
  a -= b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}
void smx(long long &a, long long b) {
  if (a < b) a = b;
}
void smn(long long &a, long long b) {
  if (a > b) a = b;
}
void ads(long long &a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
}
void mis(long long &a, long long b) {
  a -= b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long egcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long d = egcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long mbinp(long long a, long long b) {
  a %= mod;
  if (b == 0) return 1;
  long long ans = mbinp(a, b / 2);
  long long tmp = (ans * ans) % mod;
  if (b % 2) return ((tmp * a) % mod);
  return ((tmp) % mod);
}
long long binp(long long a, long long b) {
  if (b == 0) return 1;
  long long ans = binp(a, b / 2);
  long long tmp = (ans * ans);
  if (b % 2) return ((tmp * a));
  return ((tmp));
}
long long C(int n, int m) {
  long long ret = 1;
  for (int i = 1; i <= m; i++) {
    ret *= (n - i + 1);
    ret /= i;
  }
  return ret;
}
long long overbinp(long long a, int b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      if (res < INF64 / a)
        res *= a;
      else
        return INF64;
    }
    if (b > 1) {
      if (a < INF64 / a)
        a *= a;
      else
        return INF64;
    }
    b >>= 1;
  }
  return res;
}
class SparseTable {
  vector<vector<int> > sparse;
  int n;
  vector<int> input;

 private:
  int lg2(int x) {
    int out = 0;
    while ((1 << out) <= x) out++;
    return out - 1;
  }

 public:
  int rminpos(int left, int right) {
    int len = right - left + 1;
    int lg = lg2(len);
    return (input[sparse[left][lg]] < input[sparse[left + len - (1 << lg)][lg]]
                ? sparse[left][lg]
                : sparse[left + len - (1 << lg)][lg]);
  }

 public:
  SparseTable(vector<int> inp, string operation) {
    input = inp;
    n = inp.size();
    if (operation == "min") prepromin();
  }

 private:
  void prepromin() {
    sparse.resize(n);
    int x = lg2(n) + 1;
    for (int i = 0; i < n; i++) sparse[i].resize(x);
    for (int i = 0; i < n; i++) sparse[i][0] = i;
    for (int j = 1; j < x; j++)
      for (int i = 0; i + (1 << (j - 1)) < n; i++)
        sparse[i][j] =
            (input[sparse[i][j - 1]] < input[sparse[i + (1 << (j - 1))][j - 1]]
                 ? sparse[i][j - 1]
                 : sparse[i + (1 << (j - 1))][j - 1]);
  }
};
void display(vector<int> &a) {
  for (int z : a) cout << z << " ";
  cout << endl;
}
const int nax = 1e5 + 20;
int rnk[nax];
int u = 0;
int lop[nax];
void dfs(int x, vector<vector<int> > &adj, vector<int> &eul, vector<int> &bij) {
  for (int z : adj[x])
    if (rnk[z] > rnk[x]) {
      eul.push_back(rnk[x]);
      bij.push_back(x);
      lop[x] = u;
      u++;
      dfs(z, adj, eul, bij);
    }
  eul.push_back(rnk[x]);
  bij.push_back(x);
  lop[x] = u;
  u++;
}
void ddfs(int x, int par, vector<vector<int> > &adj, vector<int> &has) {
  for (int z : adj[x])
    if (par != z) {
      ddfs(z, x, adj, has);
      has[x] += has[z];
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<vector<int> > adj(n);
  vector<pair<int, int> > edg;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edg.push_back(make_pair(min(a, b), max(a, b)));
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    rnk[i] = 1e9;
  }
  queue<int> kyou;
  kyou.push(0);
  vector<int> has(n, 0);
  rnk[0] = 0;
  while (kyou.size()) {
    int frt = kyou.front();
    kyou.pop();
    for (int z : adj[frt])
      if (rnk[z] > rnk[frt] + 1) {
        rnk[z] = rnk[frt] + 1;
        kyou.push(z);
      }
  }
  vector<int> euler;
  vector<int> bij;
  dfs(0, adj, euler, bij);
  SparseTable spr = SparseTable(euler, "min");
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int lca = bij[spr.rminpos(min(lop[a], lop[b]), max(lop[a], lop[b]))];
    has[a]++;
    has[b]++;
    has[lca] -= 2;
  }
  ddfs(0, -1, adj, has);
  for (pair<int, int> a : edg) {
    cout << (rnk[a.first] < rnk[a.second] ? has[a.second] : has[a.first])
         << " ";
  }
}
