#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int v, next;
} edge[1000010];
int head[100010];
int pos;
void insert(int x, int y) {
  edge[pos].v = y;
  edge[pos].next = head[x];
  head[x] = pos++;
}
int parent[100010];
int find(int x) {
  if (parent[x] != x) parent[x] = find(parent[x]);
  return parent[x];
}
vector<int> ask[100010];
int ans[100010];
int cnt[100010];
void dfs(int now, int pre) {
  int len = ask[now].size();
  for (int i = 0; i < len; i++) {
    int v = ask[now][i];
    if (find(v) != 0) cnt[find(v)] -= 2;
  }
  cnt[now] += len;
  parent[now] = now;
  for (int i = head[now]; i != -1; i = edge[i].next) {
    int v = edge[i].v;
    if (v == pre) continue;
    dfs(v, now);
    cnt[now] += cnt[v];
    ans[i / 2] = cnt[v];
    parent[v] = now;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  pos = 0;
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    insert(x, y);
    insert(y, x);
  }
  for (int i = 1; i <= n; i++) ask[i].clear();
  int m;
  scanf("%d", &m);
  while (m--) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x == y) continue;
    ask[x].push_back(y);
    ask[y].push_back(x);
  }
  memset(parent, 0, sizeof(parent));
  memset(cnt, 0, sizeof(cnt));
  dfs(1, -1);
  for (int i = 0; i < n - 1; i++) printf("%d ", ans[i]);
  return 0;
}
