#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200005];
bool visited[200005];
int T[200005], L[200005];
int N;
int dis[200005];
int P[200005][25];
map<pair<int, int>, int> ans;
bool b = 0;
void dfs(int n) {
  visited[n] = 1;
  for (int i = 0; i < adj[n].size(); i++) {
    if (!visited[adj[n][i]]) {
      visited[adj[n][i]] = 1;
      T[adj[n][i]] = n;
      L[adj[n][i]] = L[n] + 1;
      dfs(adj[n][i]);
      dis[n] += dis[adj[n][i]];
      if (b) {
        ans[pair<int, int>(n, adj[n][i])] = dis[adj[n][i]];
      }
    }
  }
}
void LCA_init() {
  memset(P, -1, sizeof(P));
  for (int i = 1; i <= N; i++) {
    P[i][0] = T[i];
  }
  for (int k = 1; (1 << k) <= N; k++) {
    for (int i = 1; i <= N; i++) {
      if (P[i][k - 1] != -1) {
        P[i][k] = P[P[i][k - 1]][k - 1];
      }
    }
  }
}
int LCA(int p, int q) {
  if (L[q] > L[p]) {
    swap(p, q);
  }
  int log = log2(L[p]);
  for (int i = log; i >= 0; i--) {
    if (L[p] - (1 << i) >= L[q]) {
      p = P[p][i];
    }
  }
  if (p == q) return p;
  for (int i = log; i >= 0; i--) {
    if (P[p][i] != -1 && P[p][i] != P[q][i]) {
      p = P[p][i];
      q = P[q][i];
    }
  }
  return T[p];
}
int get_dist(int x, int y) {
  int lca = LCA(x, y);
  int ans = dis[x] + dis[y] - (2 * dis[lca]);
  return ans;
}
int main() {
  cin >> N;
  vector<pair<int, int> > edges;
  for (int i = 0; i < N - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    edges.push_back(pair<int, int>(u, v));
  }
  memset(T, -1, sizeof(T));
  T[1] = 1;
  dfs(1);
  LCA_init();
  int q;
  cin >> q;
  while (q--) {
    int u, v;
    cin >> u >> v;
    dis[u]++;
    dis[v]++;
    dis[LCA(u, v)] -= 2;
  }
  memset(visited, 0, sizeof(visited));
  b = 1;
  dfs(1);
  vector<int> done;
  for (auto ed : edges) {
    int u = ed.first, v = ed.second;
    if (ans[pair<int, int>(u, v)]) {
      done.push_back(ans[pair<int, int>(u, v)]);
    } else if (ans[pair<int, int>(v, u)]) {
      done.push_back(ans[pair<int, int>(v, u)]);
    } else {
      done.push_back(0);
    }
  }
  for (int i = 0; i < done.size(); i++) {
    cout << done[i] << ' ';
  }
  cout << endl;
}
