#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
int curchain, x;
int chain[100005], par[100005], chainpos[100005], base[100005], head[100005],
    basepos[100005], subsize[100005];
void dfs(int node, int pare) {
  par[node] = pare;
  for (int i = 0; i < v[node].size(); i++) {
    if (v[node][i] != pare) {
      dfs(v[node][i], node);
      subsize[node] += subsize[v[node][i]] + 1;
    }
  }
}
void hld(int node, int pos) {
  chain[node] = curchain;
  chainpos[node] = pos;
  if (head[curchain] == -1) {
    head[curchain] = node;
    basepos[curchain] = x - 1;
  }
  int sc = -1, scsize = -1;
  for (int i = 0; i < v[node].size(); i++) {
    if (v[node][i] != par[node]) {
      if (subsize[v[node][i]] > scsize) {
        scsize = subsize[v[node][i]];
        sc = i;
      }
    }
  }
  if (sc != -1) {
    base[x++] = 0;
    hld(v[node][sc], pos + 1);
    for (int i = 0; i < v[node].size(); i++) {
      if (v[node][i] != par[node] && i != sc) {
        curchain++;
        base[x++] = 0;
        hld(v[node][i], 1);
      }
    }
  }
}
vector<pair<int, int> > edges;
void dfs2(int node, int par) {
  for (int i = 0; i < v[node].size(); i++) {
    if (v[node][i] == par) continue;
    dfs2(v[node][i], node);
    base[node] += base[v[node][i]];
  }
}
int main() {
  int i, j, k;
  int n;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d", &j);
    scanf("%d", &k);
    v[j].push_back(k);
    v[k].push_back(j);
    edges.push_back(make_pair(j, k));
  }
  dfs(1, 1);
  curchain = x = 1;
  for (i = 1; i <= n; i++) head[i] = -1;
  base[0] = 0;
  hld(1, 1);
  scanf("%d", &k);
  while (k--) {
    scanf("%d", &i);
    scanf("%d", &j);
    base[i]++;
    base[j]++;
    while (chain[i] != chain[j]) {
      if (chain[i] > chain[j]) {
        i = par[head[chain[i]]];
      } else {
        j = par[head[chain[j]]];
      }
    }
    if (chainpos[i] > chainpos[j])
      base[j] -= 2;
    else
      base[i] -= 2;
  }
  dfs2(1, 0);
  for (i = 0; i < edges.size(); i++) {
    if (chain[edges[i].first] == chain[edges[i].second]) {
      if (chainpos[edges[i].first] > chainpos[edges[i].second]) {
        printf("%d ", base[edges[i].first]);
      } else
        printf("%d ", base[edges[i].second]);
    } else {
      if (chain[edges[i].first] > chain[edges[i].second]) {
        printf("%d ", base[edges[i].first]);
      } else
        printf("%d ", base[edges[i].second]);
    }
  }
  return 0;
}
