#include <bits/stdc++.h>
const long long int mo = 1e9 + 7;
const long long int INF = 1e9;
const long double pi = acos(-1);
const int mxn = 1e5 + 5;
const int cons = 1;
using namespace std;
pair<int, int> edge[mxn];
int val[mxn], ans[mxn];
vector<int> tr[mxn];
int n;
const int lg = 20;
int dt[mxn], par[mxn], dp[mxn][lg + 5];
void dfs1(int src, int pa) {
  par[src] = pa;
  int i, temp;
  for (i = 0; i < (int)tr[src].size(); i++) {
    temp = tr[src][i];
    if (temp != pa) {
      dt[temp] = dt[src] + 1;
      dfs1(temp, src);
    }
  }
}
void lca_preprocess() {
  int i, j;
  for (i = 1; i <= n; i++) {
    dp[i][0] = par[i];
  }
  for (j = 1; j <= lg; j++) {
    for (i = 1; i <= n; i++) {
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }
  }
}
int lca(int x, int y) {
  int i;
  if (dt[x] > dt[y]) {
    x = x + y;
    y = x - y;
    x = x - y;
  }
  int diff = dt[y] - dt[x];
  for (i = 0; i < lg; i++) {
    if (diff & (1 << i)) {
      y = dp[y][i];
    }
  }
  if (x == y) {
    return x;
  }
  for (i = lg - 1; i >= 0; i--) {
    if (dp[x][i] != dp[y][i]) {
      x = dp[x][i];
      y = dp[y][i];
    }
  }
  return dp[x][0];
}
void dfs2(int src, int pa) {
  ans[src] = val[src];
  int i, temp;
  for (i = 0; i < (int)tr[src].size(); i++) {
    temp = tr[src][i];
    if (temp != pa) {
      dfs2(temp, src);
      ans[src] += ans[temp];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, a, b, k, c;
  cin >> n;
  for (i = 1; i <= n - 1; i++) {
    cin >> a >> b;
    edge[i].first = a;
    edge[i].second = b;
    tr[a].push_back(b);
    tr[b].push_back(a);
  }
  dfs1(1, 1);
  lca_preprocess();
  cin >> k;
  while (k--) {
    cin >> a >> b;
    if (a == b) {
      continue;
    }
    c = lca(a, b);
    if (c != a && c != b) {
      val[a] += +1;
      val[b] += +1;
      val[c] += -2;
    } else {
      if (c == a) {
        val[a] += -1;
        val[b] += +1;
      } else {
        val[b] += -1;
        val[a] += +1;
      }
    }
  }
  dfs2(1, 1);
  for (i = 1; i <= n - 1; i++) {
    if (dt[edge[i].first] > dt[edge[i].second]) {
      cout << ans[edge[i].first] << " ";
    } else {
      cout << ans[edge[i].second] << " ";
    }
  }
  return 0;
}
