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.io.*;
import java.text.DecimalFormat;
import java.util.*;
public class l {
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////                                                                                                               /////////
////////                                                                                                               /////////
////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMM          MMMM         OOOOOO             SSSSSSS      EEEEEEEEEEEEE  /////////
////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMMMM      MMMMMM      OOO      OOO        SSSS   SSS     EEEEEEEEEEEEE  /////////
////////   HHHH        HHHH  EEEEE           MMMM MMM  MMM MMMM    OOO          OOO    SSSS       SSS   EEEEE          /////////
////////   HHHH        HHHH  EEEEE           MMMM  MMMMMM  MMMM   OOO            OOO   SSSS             EEEEE          /////////
////////   HHHH        HHHH  EEEEE           MMMM          MMMM  OOO              OOO   SSSSSSS         EEEEE          /////////
////////   HHHHHHHHHHHHHHHH  EEEEEEEEEEE     MMMM          MMMM  OOO              OOO      SSSSSS       EEEEEEEEEEE    /////////
////////   HHHHHHHHHHHHHHHH  EEEEEEEEEEE     MMMM          MMMM  OOO              OOO         SSSSSSS   EEEEEEEEEEE    /////////
////////   HHHH        HHHH  EEEEE           MMMM          MMMM   OOO            OOO              SSSS  EEEEE          /////////
////////   HHHH        HHHH  EEEEE           MMMM          MMMM    OOO          OOO     SSS       SSSS  EEEEE          /////////
////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMM          MMMM      OOO      OOO        SSS    SSSS    EEEEEEEEEEEEE  /////////
////////   HHHH        HHHH  EEEEEEEEEEEEE   MMMM          MMMM         OOOOOO             SSSSSSS      EEEEEEEEEEEEE  /////////
////////                                                                                                               /////////
////////                                                                                                               /////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    static int mod = (int) (1e9 + 7);
    static int n;
    static StringBuilder sol;

    static class pair implements Comparable<pair> {
        int left, right,val;

        public pair(int x, int y) {
            left = x;
            right = y;
        }

        public int compareTo(pair o) {
            if (o.left == left) return right - o.right;
            return left - o.left;
        }

        public String toString() {
            return left + " " + right;
        }
    }

    static class tri implements Comparable<tri> {
        int lef, righ, idx;

        tri(int a, int b, int c) {
            lef = a;
            righ = b;
            idx = c;
        }

        public int compareTo(tri o) {
            if (lef == o.lef) return righ - o.righ;
            return lef - o.lef;
        }

        public String toString() {
            return lef + " " + righ + " " + idx;
        }
    }
    static ArrayList<Integer>[]adj;
    static boolean[]vis;
    static ArrayList<Integer>ans;
    static int[]T;
    static void dfs(int u){
        vis[u]=true;
        for (int v:adj[u]){
            if (!vis[v]){
                T[v]=u;
                L[v]=1+L[u];
                dfs(v);
            }
        }
    }
    static void dfs2(int u){
        vis[u]=true;
        for (int v:adj[u]){
            if (!vis[v]){
                dfs2(v);
                pair x = new pair(Math.min(u,v),Math.max(u,v));
                x.val=vals[v];
                vals[u]+=vals[v];
                ts.add(x);
            }
        }
    }
    static int[]vals;
    static TreeSet<pair>ts= new TreeSet<>() ;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        //FileWriter f = new FileWriter("C:\\Users\\Ibrahim\\out.txt");
        PrintWriter pw = new PrintWriter(System.out);
        N = sc.nextInt();
        pair[]p = new pair[N-1];
        adj= new ArrayList[N];
        for (int i =0;i<N;i++)adj[i]= new ArrayList<>();
        for (int i =0;i<N-1;i++){
            int u = sc.nextInt()-1;
            int v = sc.nextInt()-1;
            p[i]= new pair(Math.min(u,v),Math.max(u,v));
            adj[u].add(v);
            adj[v].add(u);
        }
        L= new int[N];
        T= new int[N];
        T[0]=-1;
        vis= new boolean[N];
        dfs(0);
        preprocessParents(0,T);
        int k = sc.nextInt();
        vals= new int[N];
        while (k-->0){
            int u = sc.nextInt()-1;
            int v = sc.nextInt()-1;
            vals[u]++;
            vals[v]++;
            vals[query(u,v)]-=2;
        }
        vis= new boolean[N];
        dfs2(0);
        //System.out.println(Arrays.toString(vals)+ts);
        for (int i =0;i<N-1;i++){
            pw.print(ts.ceiling(p[i]).val+" ");
        }
        pw.flush();
    }
    static long gcd(long a ,long b){
        if (a==0)return b;
        return gcd(b%a,a);
    }

    static final int R = 26;                //Alphabet (lowercase etters in below implementation)

    static class Node {
        Node[] next = new Node[R];
        int val = -1;
        int count=0;
    }

    static int N, L[], P[][];			// P[i][j] --> the 2^j th ancestor of node i

    static void preprocessParents(int root, int[] T)	// O(n log n)
    {
        int k = 0; while(1<<k+1 < N) ++k;		// max parent = floor(log2(N - 1))

        P = new int[N][k + 1];

        for(int i = 0; i < N; i++)
            Arrays.fill(P[i], -1);

        // base case: direct parents
        for(int i = 0; i < N; ++i)
            P[i][0] = T[i];					// T[root] = -1

        for(int j = 1; j <= k; j++)
            for(int i = 0; i < N; i++)
                if(P[i][j-1] != -1)
                    P[i][j] = P[P[i][j-1]][j-1];
    }

    static int query(int p, int q)		// O(log n)
    {
        //if p is situated on a higher level than q, swap them
        if (L[p] < L[q]) { p ^= q; q ^= p; p ^= q; }

        //find largest k such that 2^k is a parent of p
        int k = 0;
        while(1<<k+1 <= L[p])
            ++k;

        //find the ancestor of p situated on the same level with q
        for (int i = k; i >= 0; --i)
            if (L[p] - (1<<i) >= L[q])
                p = P[p][i];

        if (p == q)
            return p;

        //go up to lowest (non-common) ancestors for p and q
        for (int i = k; i >= 0; --i)
            if (P[p][i] != -1 && P[p][i] != P[q][i])
            {
                p = P[p][i]; q = P[q][i];
            }

        return P[p][0];
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}