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.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.TreeMap;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.util.TreeSet;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        Graph g = new Graph(n);
        int i,j,k;

        int ei[][] = new int[n][2];
        for(k=1;k<n;++k){
            i = in.nextInt()-1;
            j = in.nextInt()-1;
            g.addBiEdge(new Edge(i,j));
            ei[k-1][0] = i;
            ei[k-1][1] = j;
        }

        Graph.LCAer lt = new Graph.LCAer(g);
        Graph.HeavyLightDecomposition d = new Graph.HeavyLightDecomposition(g);

        DataStruct.SegmentTreeSegAdd t[] = new DataStruct.SegmentTreeSegAdd[d.ways];
        for(i=0;i<d.ways;++i) t[i] = new DataStruct.SegmentTreeSegAdd(d.w[i].length);
        
        for(int m = in.nextInt();m>0;--m){
            int a = in.nextInt()-1, b = in.nextInt()-1;
            int l = lt.lca(a,b);
            
            int c[];
            if(a!=l){
                int x = lt.nextDownTo(l,a);
                c = d.query(a,x);
                for(i=0;i<c.length;i+=3){
                    t[c[i]].addRange(c[i+1],c[i+2],1);
                }
            }
            if(b!=l){
                int x = lt.nextDownTo(l,b);
                c = d.query(b,x);
                for(i=0;i<c.length;i+=3){
                    t[c[i]].addRange(c[i+1],c[i+2],1);
                }
            }
        }
        
        for(k=0;k<n-1;++k){
            i = ei[k][0];
            if(lt.nthParent(i,1)!=ei[k][1]) i = ei[k][1];
            out.write(t[d.wi[i]].getItem(d.wj[i]),' ');
        }
	}
}

class InputReader{
    private InputStream in;
    private byte buffer[] = new byte[1<<11];
    private int cur;
    private int end;
    
    
    public InputReader(InputStream stream){
        in = stream;
    }
    
    public int read(){
        if(end<0) throw new InputMismatchException();
        if(cur>=end){
            cur = 0;
            try{
                end = in.read(buffer);
            }catch(IOException e){
                throw new InputMismatchException();
            }
            if(end<=0) return -1;
        }
        return buffer[cur++];
    }
    
    public boolean isSpace(int c){
        return c==' ' || c=='\n' || c=='\r' || c=='\t' || c==-1;
    }
    
    public int nextInt(){
        int c = read(), res = 0, sign = 1;
        while(isSpace(c)) c = read();
        if(c=='-'){ sign = -1; c = read(); }
        do{
            if(c>'9' || c<'0') throw new InputMismatchException();
            res = res*10 + (c-'0');
            c = read();
        }while(!isSpace(c));
        return res*sign;
    }

    }

class OutputWriter{
    private PrintWriter out;
    
    public OutputWriter(Writer out){
        this.out = new PrintWriter(out);
    }

    public OutputWriter(OutputStream out){
        this.out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));
    }
    
    public void close(){
        out.close();
    }

    public void write(Object ... o){
        for(Object x : o) out.print(x);
    }
    
    }

class Graph{
    public int N;
    public ArrayList<Edge> edges[];
    
    public Graph(int n){
        N = n;
        edges = new ArrayList[n];
        for(int i=0;i<n;++i) edges[i] = new ArrayList<Edge>();
    }
    
    public void addBiEdge(Edge ... ex){
        for(Edge e : ex){
            edges[e.from].add(e);
            edges[e.to].add(e.inv());
        }
    }


    public static class LCAer{
        private int p[][];
        private int log;
        private Graph g;
        private int ti[], to[], tm;

        public LCAer(Graph tree){
            int n = tree.N;
            for(log=0; 1<<log<n; ++log);
            ++log;
            p = new int[log][n];
            this.g = tree;
            ti = new int[n];
            to = new int[n];
            tm = 0;
            for(int i=0;i<n;++i) if(ti[i]==0) dfs_p(i, -1);
        }

        private void dfs_p(int v, int par){
            ti[v] = ++tm;
            p[0][v] = par;
            for(int i=1;i<log;++i) p[i][v] = p[i-1][v]==-1 ? -1: p[i-1][p[i-1][v]];
            for(Edge e : g.edges[v]) if(ti[e.to]==0) dfs_p(e.to, v);
            to[v] = ++tm;
        }

        private boolean upper(int v, int u){
            return v==-1 || u!=-1 && ti[v]<ti[u] && to[v]>to[u];
        }

        public int lca(int v, int u){
            if(v==u || upper(v,u)) return v;
            if(upper(u,v)) return u;
            for(int i=log-1;i>=0;--i) if(!upper(p[i][v], u)) v = p[i][v];
            return p[0][v];
        }
        
        public int nextDownTo(int from, int downto){
            for(int i=log-1;i>=0;--i) if(upper(from, p[i][downto])) downto = p[i][downto];
            return downto;
        }
        
        public int nthParent(int v, int n){
            if(n >= 1<<log) return -1;
            for(int t=0; n<=1<<t; ++t) if((1<<t&n)!=0) v = p[t][v];
            return v;
        }
    }
    
    
    
    public static class HeavyLightDecomposition{
        private Graph g;
        private int p[], s[];
        int w[][], ways, wi[], wj[];
        private int q[];
        
        public HeavyLightDecomposition(Graph tree){
            int n = tree.N, i;
            this.g = tree;
            p = new int[n];
            Arrays.fill(p,-1);
            s = new int[n];
            for(i=0;i<n;++i) if(s[i]==0) dfs_ps(i, -1);
            wi = new int[n];
            wj = new int[n];
            ways = 0;
            for(i=0;i<n;++i) if(p[i]==-1) dfs_w(i, 0, -1);
            w = new int[ways][];
            ways = 0;
            for(i=0;i<n;++i){
                boolean h = false;
                for(Edge e : g.edges[i]) if(e.to!=p[i] && s[e.to]>0){ h=true; break; }
                if(!h){
                    w[ways] = new int[s[i]+1];
                    for(int j=i, k=0; k<w[ways].length; j=p[j], ++k){
                        w[ways][k] = j;
                        wi[j] = ways;
                        wj[j] = k;
                    }
                    ++ways;
                }
            }
            q = new int[50*3];
        }
        
        private void dfs_ps(int v, int par){
            p[v] = par;
            s[v] = 1;
            for(Edge e : g.edges[v]) if(e.to!=par){
                dfs_ps(e.to, v);
                s[v] += s[e.to];
            }
        }
        
        private void dfs_w(int v, int hc, int par){
            boolean h = false;
            for(Edge e : g.edges[v]) if(e.to!=par){
                if(s[e.to]*2>=s[v]){
                    h = true;
                    dfs_w(e.to, hc+1, v);
                }else dfs_w(e.to, 0, v);
            }
            s[v] = hc;
            if(!h) ++ways; 
        }
        
        public int[] query(int from, int to){
            int m = 0;
            for(;;){
                int fi = wi[from];
                int end = w[fi][w[fi].length-1];
                if(fi==wi[to]) end = to;
                q[m++] = fi;
                q[m++] = wj[from];
                q[m++] = wj[end];
                if(end==to) break;
                from = p[end];
            }
            return Arrays.copyOf(q, m);
        }
    }
    
}

class Edge{
    public int from, to;
    
    public Edge(int _form, int _to){
        from =  _form;
        to = _to;
    }

    public Edge(){}
    
    public Edge inv(){
        return new Edge(to, from);
    }

    }

class DataStruct {

    public static class SegmentTreeSegAdd{
        private int t[];
        int d;

        public SegmentTreeSegAdd(int n){
            for(d=1; d<n; d<<=1);
            t = new int[d<<1];
        }

        public SegmentTreeSegAdd(int[] array){
            int n = array.length, i;
            for(d=1; d<n; d<<=1);
            t = new int[d<<1];
            for(i=d; i<n+d; ++i) t[i] = array[i-d];
        }

        public void addRange(int left, int right, int value){
            for(int i=left+d, j=right+d; i<=j;){
                int k = Math.min(i&-i, Integer.highestOneBit(j-i+1));
                t[i/k] += value;
                i+=k;
            }
        }

        public int getItem(int index){
            int i, res = 0;
            for(i=index+d; i>0; i>>=1) res += t[i];
            return res;
        }
    }
    
    
    
    }

