#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000 + 10;
const int INF = 1000000000;
struct Edge {
  int t, w, id;
  Edge *n;
} * tot_Edge;
struct Node {
  Node *ch[2];
  Node *p;
  int isroot;
  int id, size;
  int val, sum, maxv, minv;
  int rev, add, cov, iscov;
  bool dir();
  void set(Node *, bool);
  void Update();
  void Relax();
  void App_Rev();
  void App_Cov(int);
  void App_Add(int);
} * Null, *tot_Node;
int N;
Node nodes[MAX_N];
Node *pos[MAX_N];
Node *epos[MAX_N];
Edge edges[MAX_N * 2];
Edge *E[MAX_N];
Node *New_Node(int id, int val, Node *p) {
  Node *t = tot_Node++;
  t->p = p;
  t->ch[0] = t->ch[1] = Null;
  t->isroot = true;
  t->id = id;
  t->size = 1;
  t->val = t->sum = t->maxv = t->minv = val;
  t->rev = t->add = t->iscov = 0;
  return t;
}
void Init_Null() {
  Null = New_Node(0, 0, Null);
  Null->size = Null->sum = 0;
  Null->val = Null->maxv = Null->minv = -INF;
}
void rot(Node *t) {
  Node *p = t->p;
  bool d = t->dir();
  p->Relax();
  t->Relax();
  p->set(t->ch[!d], d);
  if (p->isroot)
    t->p = p->p;
  else
    p->p->set(t, p->dir());
  t->set(p, !d);
  if (p->isroot) swap(p->isroot, t->isroot);
  p->Update();
}
void Splay(Node *t) {
  for (t->Relax(); !t->isroot;) {
    if (t->p->isroot)
      rot(t);
    else
      t->dir() == t->p->dir() ? (rot(t->p), rot(t)) : (rot(t), rot(t));
  }
  t->Update();
}
void Access(Node *t) {
  for (Node *s = Null; t != Null; s = t, t = t->p) {
    Splay(t);
    t->ch[1]->isroot = true;
    t->ch[1] = s;
    s->isroot = false;
    t->Update();
  }
}
void AccessAdd(Node *t) {
  for (Node *s = Null; t != Null; s = t, t = t->p) {
    Splay(t);
    if (t->p == Null) {
      t->ch[1]->App_Add(1);
      s->App_Add(1);
    }
    t->ch[1]->isroot = true;
    t->ch[1] = s;
    s->isroot = false;
    t->Update();
  }
}
void AccessQ(Node *t) {
  Node *s, *w = t;
  for (s = Null; t != Null; s = t, t = t->p) {
    Splay(t);
    t->ch[1]->isroot = true;
    t->ch[1] = s;
    s->isroot = false;
    t->Update();
  }
  printf("%d ", w->val);
}
void addEdge(int s, int t, int id) {
  Edge *e = tot_Edge++;
  e->t = t;
  e->id = id;
  e->n = E[s];
  E[s] = e;
}
void BFS(int s) {
  int u, v;
  queue<int> Q;
  pos[s] = New_Node(s, 0, Null);
  for (Q.push(s); !Q.empty();) {
    u = Q.front();
    Q.pop();
    for (Edge *e = E[u]; e; e = e->n)
      if ((v = e->t) != pos[u]->p->id) {
        epos[e->id] = pos[v] = New_Node(v, 0, pos[u]);
        Q.push(v);
      }
  }
}
void Init() {
  int s, t, w;
  tot_Node = nodes;
  Init_Null();
  tot_Edge = edges;
  scanf("%d", &N);
  for (int i = 1; i < N; ++i) {
    scanf("%d%d", &s, &t);
    addEdge(s, t, i);
    addEdge(t, s, i);
  }
  BFS(1);
}
void Solve() {
  int K, s, t;
  scanf("%d", &K);
  for (int i = 0; i < K; ++i) {
    scanf("%d%d", &s, &t);
    Access(pos[t]);
    AccessAdd(pos[s]);
  }
  for (int i = 1; i < N; ++i) AccessQ(epos[i]);
}
int main() {
  Init();
  Solve();
  return 0;
}
bool Node::dir() { return this == p->ch[1]; }
void Node::set(Node *t, bool _d) {
  ch[_d] = t;
  t->p = this;
}
void Node::Update() {
  size = ch[0]->size + ch[1]->size + 1;
  sum = ch[0]->sum + ch[1]->sum + val;
  maxv = max(max(ch[0]->maxv, ch[1]->maxv), val);
  minv = min(min(ch[0]->minv, ch[1]->minv), val);
}
void Node::Relax() {
  if (rev) {
    ch[0]->App_Rev();
    ch[1]->App_Rev();
    rev = false;
  }
  if (iscov) {
    ch[0]->App_Cov(cov);
    ch[1]->App_Cov(cov);
    iscov = false;
  }
  if (add) {
    ch[0]->App_Add(add);
    ch[1]->App_Add(add);
    add = 0;
  }
}
void Node::App_Rev() {
  if (this == Null) return;
  swap(ch[0], ch[1]);
  rev ^= true;
}
void Node::App_Cov(int cov) {
  if (this == Null) return;
  minv = maxv = val = cov;
  sum = size * cov;
  iscov = true;
  cov = cov;
}
void Node::App_Add(int x) {
  if (this == Null) return;
  minv += x;
  maxv += x;
  val += x;
  sum += size * x;
  add += x;
}
