They say that Berland has exactly two problems, fools and roads. Besides, Berland has n cities, populated by the fools and connected by the roads. All Berland roads are bidirectional. As there are many fools in Berland, between each pair of cities there is a path (or else the fools would get upset). Also, between each pair of cities there is no more than one simple path (or else the fools would get lost). 

But that is not the end of Berland's special features. In this country fools sometimes visit each other and thus spoil the roads. The fools aren't very smart, so they always use only the simple paths.

A simple path is the path which goes through every Berland city not more than once.

The Berland government knows the paths which the fools use. Help the government count for each road, how many distinct fools can go on it.

Note how the fools' paths are given in the input.

Input

The first line contains a single integer n (2 ≤ n ≤ 105) — the number of cities. 

Each of the next n - 1 lines contains two space-separated integers ui, vi (1 ≤ ui, vi ≤ n, ui ≠ vi), that means that there is a road connecting cities ui and vi. 

The next line contains integer k (0 ≤ k ≤ 105) — the number of pairs of fools who visit each other. 

Next k lines contain two space-separated numbers. The i-th line (i > 0) contains numbers ai, bi (1 ≤ ai, bi ≤ n). That means that the fool number 2i - 1 lives in city ai and visits the fool number 2i, who lives in city bi. The given pairs describe simple paths, because between every pair of cities there is only one simple path.

Output

Print n - 1 integer. The integers should be separated by spaces. The i-th number should equal the number of fools who can go on the i-th road. The roads are numbered starting from one in the order, in which they occur in the input.

Examples

Input

5
1 2
1 3
2 4
2 5
2
1 4
3 5


Output

2 1 1 1 


Input

5
3 4
4 5
1 4
2 4
3
2 3
1 3
3 5


Output

3 1 1 1 

Note

In the first sample the fool number one goes on the first and third road and the fool number 3 goes on the second, first and fourth ones.

In the second sample, the fools number 1, 3 and 5 go on the first road, the fool number 5 will go on the second road, on the third road goes the fool number 3, and on the fourth one goes fool number 1.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class FoolsAndRoads {
    private static class Node {
        private int id;
        private int level;
        private HashMap<Integer, Integer> conns;

        public Node(int id) {
            this.id = id;
            this.conns = new HashMap<>();
            this.level = -1;
        }

        public void addConn(int nodeId, int edgeId) {
            conns.put(nodeId, edgeId);
        }

        public Collection<Integer> getConnections() {
            return conns.keySet();
        }

        public Integer getEdge(int nodeId) {
            Integer edgeId = conns.get(nodeId);
            assert edgeId != null;
            return edgeId;
        }

        public int getId() {
            return id;
        }

        public int getLevel() {
            return level;
        }

        public void setLevel(int level) {
            this.level = level;
        }
    }

    private static class Graph {
        private int numNodes;
        private int maxLog;

        private Node[] nodes;
        private Node[] parents;
        private Node[][] ptable;

        public Graph(int numNodes) {
            this.numNodes = numNodes;
            this.maxLog = log2(numNodes) + 1;

            this.nodes = new Node[numNodes];
            this.parents = new Node[numNodes];
            this.ptable = new Node[numNodes][this.maxLog];
        }

        public Node[] getNodes() {
            return nodes;
        }

        public void addNode(int id) {
            if (this.nodes[id] == null) {
                this.nodes[id] = new Node(id);
            }
        }

        public void addEdge(int nodeIdA, int nodeIdB, int edgeId) {
            this.nodes[nodeIdA].addConn(nodeIdB, edgeId);
            this.nodes[nodeIdB].addConn(nodeIdA, edgeId);
        }

        public Node getNodeById(int nodeId) {
            assert this.nodes[nodeId] != null;
            return this.nodes[nodeId];
        }

        public Node getParent(Node n) {
            return this.parents[n.getId()];
        }

        public void initialise() {
            buildTree();
            buildPTable();
        }

        public Node findLCA(Node a, Node b) {
            if (a.level > b.level) {
                Node tmp = a;
                a = b;
                b = tmp;
            }

            int diff = b.getLevel() - a.getLevel();
            while (diff > 0) {
                int ld = log2(diff);
                b = ptable[b.getId()][ld];
                diff -= (1 << ld);
            }
            if (a.getId() == b.getId()) {
                return a;
            }
            for (int i = maxLog - 1; i >= 0; i--) {
                if (ptable[a.getId()][i] != null && (ptable[a.getId()][i] != ptable[b.getId()][i])) {
                    a = ptable[a.getId()][i];
                    b = ptable[b.getId()][i];
                }
            }

            assert parents[a.getId()] != null;
            return parents[a.getId()];
        }

        private class NodeMeta {
            public Node parent;
            public Node node;

            public NodeMeta(Node node, Node parent) {
                this.node = node;
                this.parent = parent;
            }
        }

        private void buildTree() {
            Queue<NodeMeta> queue = new LinkedList<>();
            nodes[0].setLevel(0);
            queue.add(new NodeMeta(nodes[0], null));

            boolean[] visited = new boolean[numNodes];
            while (!queue.isEmpty()) {
                NodeMeta nm = queue.poll();
                if (visited[nm.node.getId()]) {
                    continue;
                }

                parents[nm.node.getId()] = nm.parent;
                if (nm.parent != null) {
                    nm.node.setLevel(nm.parent.getLevel() + 1);
                }

                nm.node.getConnections().forEach(nid -> {
                    queue.add(new NodeMeta(nodes[nid], nm.node));
                });

                visited[nm.node.getId()] = true;
            }
        }

        private void buildPTable() {
            for (Node n : nodes) {
                ptable[n.getId()][0] = parents[n.getId()];
            }
            for (int i = 1; i < maxLog; i++) {
                for (Node n : nodes) {
                    int nid = n.getId();
                    Node p = ptable[nid][i - 1];
                    if (p != null) {
                        ptable[nid][i] = ptable[p.getId()][i - 1];
                    }
                }
            }
        }

        public int getNumNodes() {
            return numNodes;
        }
    }

    private static class Route {
        public int fromId;
        public int toId;

        public Route(int fromId, int toId) {
            this.fromId = fromId;
            this.toId = toId;
        }
    }

    private static int[] countDamage(Graph g, Collection<Route> routes) {
        int[] damage = new int[g.getNumNodes() - 1];
        int[] track = new int[g.getNumNodes()];

        routes.forEach(r -> {
            Node fromNode = g.getNodeById(r.fromId);
            Node toNode = g.getNodeById(r.toId);
            Node lcaNode = g.findLCA(fromNode, toNode);

            track[fromNode.getId()]++;
            track[toNode.getId()]++;
            track[lcaNode.getId()] -= 2;
        });

        Node[] nodes = Arrays.copyOf(g.getNodes(), g.getNumNodes());
        Arrays.sort(nodes, (o1, o2) -> Integer.compare(o2.getLevel(), o1.getLevel()));

        boolean[] visited = new boolean[g.getNumNodes()];
        for (Node n : nodes) {
            if (visited[n.getId()]) {
                continue;
            }

            visited[n.getId()] = true;
            Node p = g.getParent(n);
            if (p != null) {
                track[p.getId()] += track[n.getId()];
                int edgeId = n.getEdge(p.getId());
                damage[edgeId] += track[n.getId()];
            }
        }

        return damage;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numNodes = sc.nextInt();
        sc.nextLine();
        Graph g = new Graph(numNodes);

        for (int i = 0; i < numNodes - 1; i++) {
            List<Integer> vals = readPair(sc);
            g.addNode(vals.get(0));
            g.addNode(vals.get(1));
            g.addEdge(vals.get(0), vals.get(1), i);
        }

        g.initialise();
        int numJourneys = sc.nextInt();
        sc.nextLine();
        List<Route> journeys = new LinkedList<>();
        for (int i = 0; i < numJourneys; i++) {
            List<Integer> vals = readPair(sc);
            journeys.add(new Route(vals.get(0), vals.get(1)));
        }

        int[] damage = countDamage(g, journeys);
        for (int d : damage) {
            System.out.print(d + " ");
        }
        System.out.println();
    }

    private static List<Integer> readPair(Scanner sc) {
        String in = sc.nextLine();
        String[] items = in.split("\\s+");
        assert items.length == 2;

        List<Integer> ret = new ArrayList<>();
        ret.add(Integer.valueOf(items[0]) - 1);
        ret.add(Integer.valueOf(items[1]) - 1);
        return ret;
    }


    private static int log2(long num) {
        int log = 0;
        for (long n = num >>> 1; n > 0; n >>>= 1, log++);
        return log;
    }
}
