import java.awt.Point;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.LinkedList;

public class R121_D1_C {

    // parent of the root (0) is itself (0);
    // root is always heavy
    // heavy[node] represent that edge reaching this node is heavy

    static int[] parent;
    static int[] chain;
    static int n;
    static int[] size;
    static LinkedList<Point> edges[];
    static boolean[] heavy;
    static int[] depth;
    static int[] res;
    static int[] oo;

    public static void dfs(int node, int d) {
        depth[node] = d;
        size[node] = 1;
        chain[node] = node;
        for (Point edge : edges[node]) {
            if (size[edge.x] == 0) {
                dfs(edge.x, d + 1);
                size[node] += size[edge.x];
                parent[edge.x] = node;
            }
        }

        for (Point edge : edges[node]) {
            // to avoid edge to ur parent.
            if (parent[edge.x] == node && size[edge.x] * 2 > size[node]) {
                heavy[edge.x] = true;
            }
        }
    }

    public static void hld(int node) {
        chain[node] = heavy[node] ? chain[parent[node]] : node;
        for (Point edge : edges[node]) {
            if (parent[edge.x] == node) {
                hld(edge.x);
            }
        }
    }

    public static int lca(int a, int b) {
        while (chain[a] != chain[b]) {
            if (depth[chain[a]] < depth[chain[b]]) {
                b = parent[chain[b]];
            } else {
                a = parent[chain[a]];
            }
        }
        return depth[a] < depth[b] ? a : b;
    }

    public static int call(int node) {
        int r = res[node];
        for (Point edge : edges[node]) {
            if (parent[edge.x] == node) {
                oo[edge.y] = call(edge.x);
                r += oo[edge.y];
            }
        }
        return r;
    }

    public static void precompute() {
        chain = new int[n];
        size = new int[n];
        depth = new int[n];
        heavy = new boolean[n];
        parent = new int[n];
        dfs(0, 0);
    }

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = in.readInt();
        edges = new LinkedList[n];
        for (int i = 0; i < n; i++) {
            edges[i] = new LinkedList<Point>();
        }
        for (int i = 0; i < n - 1; i++) {
            int a = in.readInt() - 1;
            int b = in.readInt() - 1;
            edges[a].add(new Point(b, i));
            edges[b].add(new Point(a, i));
        }
        precompute();
        int q = in.readInt();
        res = new int[n];
        oo = new int[n - 1];
        for (int i = 0; i < q; i++) {
            int a = in.readInt() - 1;
            int b = in.readInt() - 1;
            res[a]++;
            res[b]++;
            res[lca(a, b)] -= 2;
        }
        call(0);
        for (int i = 0; i < n - 1; i++) {
            out.print(oo[i]+" ");
        }
        out.flush();
        out.close();
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1000];
        private int curChar, numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private String readLine0() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0)
                s = readLine0();
            return s;
        }

        public String readLine(boolean ignoreEmptyLines) {
            if (ignoreEmptyLines)
                return readLine();
            else
                return readLine0();
        }

        public char readCharacter() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            return (char) c;
        }

        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
    }

}


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.LinkedList;

public class tt {

    // parent of the root (0) is itself (0);
    // root is always heavy
    // heavy[node] represent that edge reaching this node is heavy

    static int[] parent;
    static int[] chain;
    static int n;
    static int[] size;
    static ArrayList<Integer> edges[];
    static ArrayList<Integer> indexes[];

    static boolean[] heavy;
    static int[] depth;
    static int[] res;
    static int[] oo;

    public static void dfs(int node, int d) {
        depth[node] = d;
        size[node] = 1;
        chain[node] = node;
        for (int edge : edges[node]) {
            if (size[edge] == 0) {
                dfs(edge, d + 1);
                size[node] += size[edge];
                parent[edge] = node;
            }
        }

        for (int edge : edges[node]) {
            // to avoid edge to ur parent.
            if (parent[edge] == node && size[edge] * 2 > size[node]) {
                heavy[edge] = true;
            }
        }
    }

    public static void hld(int node) {
        chain[node] = heavy[node] ? chain[parent[node]] : node;
        for (int edge : edges[node]) {
            if (parent[edge] == node) {
                hld(edge);
            }
        }
    }

    public static int lca(int a, int b) {
        while (chain[a] != chain[b]) {
            if (depth[chain[a]] < depth[chain[b]]) {
                b = parent[chain[b]];
            } else {
                a = parent[chain[a]];
            }
        }
        return depth[a] < depth[b] ? a : b;
    }

    public static int call(int node) {
        int r = res[node];
        int i = 0;
        for (int edge : edges[node]) {
            if (parent[edge] == node) {
                r += oo[indexes[node].get(i)] = call(edge);
            }
            i++;
        }
        return r;
    }

    public static void precompute() {
        chain = new int[n];
        size = new int[n];
        depth = new int[n];
        heavy = new boolean[n];
        parent = new int[n];
        dfs(0, 0);
    }

    public static void main(String[] args) throws Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n = in.readInt();
        edges = new ArrayList[n];
        indexes = new ArrayList[n];

        for (int i = 0; i < n; i++) {
            edges[i] = new ArrayList<Integer>();
            indexes[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < n - 1; i++) {
            int a = in.readInt() - 1;
            int b = in.readInt() - 1;
            edges[a].add(b);
            indexes[a].add(i);
            edges[b].add(a);
            indexes[b].add(i);
        }
        precompute();
        int q = in.readInt();
        res = new int[n];
        oo = new int[n - 1];
        for (int i = 0; i < q; i++) {
            int a = in.readInt() - 1;
            int b = in.readInt() - 1;
            res[a]++;
            res[b]++;
            res[lca(a, b)] -= 2;
        }
        call(0);
        for (int i = 0; i < n - 1; i++) {
            out.println(oo[i]);
        }
        out.flush();
        out.close();
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1000];
        private int curChar, numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private String readLine0() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public String readLine() {
            String s = readLine0();
            while (s.trim().length() == 0)
                s = readLine0();
            return s;
        }

        public String readLine(boolean ignoreEmptyLines) {
            if (ignoreEmptyLines)
                return readLine();
            else
                return readLine0();
        }

        public char readCharacter() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            return (char) c;
        }

        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
    }

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

#define NN 200200

bool rev[NN];

int pa[NN], son[NN][2], val[NN], flag[NN];

void init_LCT(int n){

	for(int i=0; i<=n; i++){

		rev[i]=val[i]=flag[i]=0;

		pa[i]=son[i][0]=son[i][1]=0;

	}

}

void push_up(int x){

	int L=son[x][0], R=son[x][1];

}

void push_down(int x){

	if(rev[x]){

		swap(son[x][0], son[x][1]);

		rev[son[x][0]]^=1;

		rev[son[x][1]]^=1;

		rev[x]=0;

	}

	if(flag[x]){

		flag[son[x][0]]+=flag[x];

		val[son[x][0]]+=flag[x];

		flag[son[x][1]]+=flag[x];

		val[son[x][1]]+=flag[x];

		flag[x]=0;

	}

}

bool isroot(int x){

	return son[pa[x]][0]!=x && son[pa[x]][1]!=x;

}

void down(int x){

	if(!isroot(x)) down(pa[x]);

	push_down(x);

}

void rot(int x, int d){

	int y=pa[x], z=pa[y];

	son[y][!d]=son[x][d];

	pa[son[x][d]]=y;

	pa[x]=pa[y];

	if(son[z][0]==y) son[z][0]=x;

	else if(son[z][1]==y) son[z][1]=x;

	pa[y]=x; son[x][d]=y;

	push_up(y);

}

void splay(int x){

	down(x);

	while(!isroot(x)){

		if(isroot(pa[x])) rot(x, son[pa[x]][0]==x);

		else {

			int y=pa[x], z=pa[y];

			int d=(son[z][0]==y);

			son[y][d]==x ? rot(x, !d) : rot(y, d);

			rot(x, d);

		}

	}

	push_up(x);

}

void access(int x){

	for(int y=0; x; x=pa[x]){

		splay(x);

		son[x][1]=y;

		push_up(y=x);

	}

}

void make_root(int x){

	access(x); splay(x); rev[x]^=1;

}

void link(int x, int y){

	make_root(x);

	splay(x); pa[x]=y;

}

void cut(int x, int y){

	make_root(x);

	splay(y);

	pa[son[y][0]]=pa[y];

	pa[y]=son[y][0]=0;

}

int getpa(int v){

	access(v); splay(v);

	while(son[v][0]) v=son[v][0];

	splay(v);

	return v;

}

int main() {

	int n, u, v;

	cin >> n;

	int cnt=n;

	for(int i=1; i<n; i++){

		scanf("%d %d", &u, &v);

		cnt++;

		link(u, cnt);

		link(v, cnt);

	}

	int k;

	cin >> k;

	for(int i=0; i<k; i++){

		scanf("%d %d", &u, &v);

		make_root(u);

		access(v);

		splay(u);

		flag[u]++;

		val[u]++;

	}

	for(int i=1; i<n; i++){

		make_root(n+i);

		access(n+i);

		printf("%d ", val[n+i]);

	}

	return 0;

}


#include <functional>

#include <algorithm>

#include <memory.h>

#include <string.h>

#include <ctype.h>

#include <stdio.h>

#include <bitset>

#include <string>

#include <vector>

#include <queue>

#include <stack>

#include <cmath>

#include <map>

#include <set>

using namespace std;

typedef long long INT;

typedef pair <int, int> pii;

typedef pair <int, pii> p3i;

#define NN 100010

#define MM (2*NN)

int K, N;

int to[MM], next[MM], fir[NN], ans[NN], cnt[NN];

int deep[NN], par[NN][20], p[NN];

void prepare() {

	int i, j;

	for (i=0; i<N; i++) for (j=0; (1<<j)<N; j++) par[i][j]=-1;

	for (i=0; i<N; i++) par[i][0]=p[i];

	for (j=1; (1<<j)<N; j++) for (i=0; i<N; i++)

		if (par[i][j-1]!=-1) par[i][j]=par[par[i][j-1]][j-1];

}

int lca(int u, int v) {

	int tmp, log, i;

	if (deep[u]<deep[v]) swap(u, v);

	for (log=1; (1<<log)<=deep[u]; log++) ;

	log--;

	for (i=log; i>=0; i--) if (deep[u]-(1<<i)>=deep[v]) u=par[u][i];

	if(u==v) return u;

	for (i=log; i>=0; i--)

		if (par[u][i]!=-1 && par[u][i]!=par[v][i])

			u=par[u][i], v=par[v][i];

	return p[u];

}

void AddEdge(int u, int v) {

	to[K]=v; next[K]=fir[u]; fir[u]=K++;

	to[K]=u; next[K]=fir[v]; fir[v]=K++;

}

void dfs(int u) {

	int i, v;

	for (i=fir[u]; i!=-1; i=next[i]) {

		v=to[i];

		if (v==p[u]) continue;

		p[v]=u; deep[v]=deep[u]+1;

		dfs(v);

	}

}

void calc(int u) {

	int i, v, j=-1;

	for (i=fir[u]; i!=-1; i=next[i]) {

		v=to[i];

		if (v==p[u]) { j=i; continue; }

		calc(v);

		cnt[u]+=cnt[v];

	}

	if (j>=0) ans[j]=ans[j^1]=cnt[u];

}

int main() {

 	int u, v, w, i, Q;

	scanf("%d ", &N);

	K=0;

	memset(fir, 0xff, sizeof(fir));

	for (i=0; i<N-1; i++) {

		scanf("%d %d ", &u, &v);

		u--; v--;

		AddEdge(u, v);

	}

	p[0]=-1; deep[0]=0;

	dfs(0);

	prepare();

	for (scanf("%d ", &Q); Q--; ) {

		scanf("%d %d ", &u, &v);

		u--; v--;

		w=lca(u, v);

		cnt[u]++; cnt[v]++; cnt[w]-=2;

	}

	calc(0);

	for (i=0; i<K; i+=2) printf("%d%c", ans[i], i<K-2?' ':'\n');

    return 0;

}


#include <algorithm>

#include <stdio.h>

#include <memory.h>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string.h>

#include <string>

#include <ctype.h>

#include <ctime>

#include <complex>

#include <bitset>

using namespace std;

typedef long long INT;

typedef pair<int, int> pii;

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template <class T> inline void chkmin(T &a, T b) { if (a>b) a=b; }

template <class T> inline void chkmax(T &a, T b) { if (a<b) a=b; }

#define NN 110000

int node[NN*2], next[NN*2], first[NN], M;

int a[NN], b[NN];

int ans[NN], dp[NN], par[NN][20], id[NN];

bool cmp(int u, int v) {

	return dp[u]<dp[v];

}

int LCA(int u, int v) {

	int i;

	if (dp[u]>dp[v]) swap(u, v);

	for (i=19; i>=0; i--)

		if (dp[v]-dp[u]>=(1<<i)) v=par[v][i];

	if (u==v) return u;

	for (i=19; i>=0; i--)

		if (par[u][i]!=par[v][i]) u=par[u][i], v=par[v][i];

	return par[u][0];

}

int dfs(int u, int p) {

	int i, v;

	for (i=first[u]; i; i=next[i]) {

		v=node[i];

		if (v==p) continue;

		dp[v]=dp[u]+1; par[v][0]=u;

		dfs(v, u);

	}

}

int main() {

	int N, K, i, j, u, v, w;

	scanf("%d", &N);

	for (i=1; i<N; i++) {

		scanf("%d%d", &u, &v);

		node[++M]=v; next[M]=first[u]; first[u]=M;

		node[++M]=u; next[M]=first[v]; first[v]=M;

		a[i]=u; b[i]=v;

	}

	dp[1]=0; dfs(1, 0);

	for (j=1; j<20; j++)

		for (i=1; i<=N; i++)

			par[i][j]=par[par[i][j-1]][j-1];

	for (scanf("%d", &K); K--; ) {

		scanf("%d%d", &u, &v);

		w=LCA(u, v);

		ans[u]++; ans[v]++; ans[w]-=2;

	}

	for (i=0; i<N; i++) id[i]=i+1;

	sort(id, id+N, cmp);

	for (i=N-1; i>=0; i--) {

		u=id[i]; v=par[u][0];

		ans[v]+=ans[u];

	}

	for (i=1; i<N; i++) {

		if (dp[a[i]]>dp[b[i]]) swap(a[i], b[i]);

		printf("%d%c", ans[b[i]], i==N-1?'\n':' ');

	}

	return 0;

}


#include <algorithm>

#include <stdio.h>

#include <memory.h>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string.h>

#include <string>

#include <ctype.h>

#include <ctime>

#include <complex>

#include <bitset>

using namespace std;

typedef long long INT;

typedef pair<int, int> pii;

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template <class T> inline void chkmin(T &a, T b) { if (a>b) a=b; }

template <class T> inline void chkmax(T &a, T b) { if (a<b) a=b; }

#define NN 110000

int node[NN*2], next[NN*2], first[NN], M;

int a[NN], b[NN];

int ans[NN], dp[NN], par[NN][20], id[NN];

bool cmp(int u, int v) {

	return dp[u]<dp[v];

}

int LCA(int u, int v) {

	int i;

	if (dp[u]>dp[v]) swap(u, v);

	for (i=19; i>=0; i--)

		if (dp[v]-dp[u]>=(1<<i)) v=par[v][i];

	if (u==v) return u;

	for (i=19; i>=0; i--)

		if (par[u][i]!=par[v][i]) u=par[u][i], v=par[v][i];

	return par[u][0];

}

int dfs(int u, int p) {

	int i, v;

	for (i=first[u]; i; i=next[i]) {

		v=node[i];

		if (v==p) continue;

		dp[v]=dp[u]+1; par[v][0]=u;

		dfs(v, u);

	}

}

int main() {

	int N, K, i, j, u, v, w;

	scanf("%d", &N);

	for (i=1; i<N; i++) {

		scanf("%d%d", &u, &v);

		node[++M]=v; next[M]=first[u]; first[u]=M;

		node[++M]=u; next[M]=first[v]; first[v]=M;

		a[i]=u; b[i]=v;

	}

	dp[1]=0; dfs(1, 0);

	for (j=1; j<20; j++)

		for (i=1; i<=N; i++)

			par[i][j]=par[par[i][j-1]][j-1];

	for (scanf("%d", &K); K--; ) {

		scanf("%d%d", &u, &v);

		w=LCA(u, v);

		ans[u]++; ans[v]++; ans[w]-=2;

	}

	for (i=0; i<N; i++) id[i]=i+1;

	sort(id, id+N, cmp);

	for (i=N-1; i>=0; i--) {

		u=id[i]; v=par[u][0];

		ans[v]+=ans[u];

	}

	for (i=1; i<N; i++) {

		if (dp[a[i]]>dp[b[i]]) swap(a[i], b[i]);

		printf("%d ", ans[b[i]]);

	}

	puts("");

	return 0;

}


//writer：Sakura
//problem：Fools and Roads
//id：191C/192E
//from：Codeforces
//matrix：another

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bits/stdc++.h>
#define N 100005
using namespace std;

typedef long long ll;

int n;
vector <pair<int,int> > vec[100005];
int x,y,q;
int depth[100005],par[55][100005],sum[100005],res[100005];

void dfs_lca(int x,int p,int d){
	depth[x]=d;
	par[0][x]=p;
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first!=p) dfs_lca(vec[x][i].first,x,d+1);
	}
}

void init(){
	memset(par,-1,sizeof(par));
	dfs_lca(0,0,0);
	for(int k=0;k<55-1;k++){
		for(int i=0;i<n;i++){
			if(par[k][i]==-1){
				par[k+1][i]=-1;
			}
			else{
				par[k+1][i]=par[k][par[k][i]];
			}
		}
	}
}

int lca(int u,int v){
	if(depth[u]<depth[v])swap(u,v);
	for(int i=0;i<55;i++){
		if(((depth[u]-depth[v])&(1<<i))) u=par[i][u];
	}
	if(u==v) return u;
	for(int i=55-1;i>=0;i--){
		if(par[i][u]!=par[i][v]){
			u=par[i][u];
			v=par[i][v];
		}
	}
	return par[0][u];
}

int dfs(int x,int p){
	int ans=sum[x];
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first==p) continue;
		res[vec[x][i].second]=dfs(vec[x][i].first,x);
		ans+=res[vec[x][i].second];
	}
	return ans;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		scanf("%d%d",&x,&y);x--;y--;
		vec[x].push_back(make_pair(y,i));
		vec[y].push_back(make_pair(x,i));
	}
	init();
	scanf("%d",&q);
	int x,y;
	for(int i=1;i<=q;i++){
		scanf("%d%d",&x,&y);x--;y--;
		int z=lca(x,y);
		sum[x]++;
		sum[y]++;
		sum[z]-=2;
	}
	dfs(0,-1);
	for(int i=0;i<n-1;i++){
		printf("%d ",res[i]);
	}puts("");
	return 0;
}


//writer：Sakura
//problem：Fools and Roads
//id：191C/192E
//from：Codeforces
//matrix：another

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bits/stdc++.h>
#define N 100005
using namespace std;

typedef long long ll;

int n;
int dep[N],par[55][N],sum[N],ans[N];
vector<pair<int,int> > vec[N];

void dfs_lca(int x,int p,int d){
	par[0][x]=p;dep[x]=d;
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first!=p)dfs_lca(vec[x][i].first,x,d+1);
	}
}

void init(){
	memset(par,-1,sizeof(par));
	dfs_lca(0,0,0);
	for(int k=0;k<55-1;k++){
		for(int i=0;i<n;i++){
			if(par[k][i]==-1){
				par[k+1][i]=-1;
			}
			else{
				par[k+1][i]=par[k][par[k][i]];
			}
		}
	}
}

int LCA(int u,int v){
	if(dep[u]<dep[v])swap(u,v);
	for(int i=0;i<55-1;i++){
		if((dep[u]-dep[v])&(1<<i))u=par[i][u];
	}
	if(u==v)return u;
	for(int i=55-1;i>=0;i--){
		if(par[i][u]!=par[i][v]){
			u=par[i][u];
			v=par[i][v];
		}
	}
	return par[0][u];
}

int dfs(int x,int p){
	int res=sum[x];
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first==p)continue;
		ans[vec[x][i].second]=dfs(vec[x][i].first,x);
		res+=ans[vec[x][i].second];
	}
	return res;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(make_pair(b,i));
		vec[b].push_back(make_pair(a,i));
	}
	init();
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--,b--;
		int c=LCA(a,b);
		sum[a]++,sum[b]++,sum[c]-=2;
	}
	dfs(0,-1);
	for(int i=0;i<n-1;i++){
		printf("%d ",ans[i]);
	}puts("");
	return 0;
}


//writer：Sakura
//problem：Fools and Roads
//id：191C/192E
//from：Codeforces
//matrix：another

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bits/stdc++.h>
#define N 100005
using namespace std;

typedef long long ll;

int n;
int dep[N],par[55][N],sum[N],ans[N];
vector<pair<int,int> > vec[N];
int x,y,q;

void dfs_lca(int x,int p,int d){
	par[0][x]=p;dep[x]=d;
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first!=p)dfs_lca(vec[x][i].first,x,d+1);
	}
}

void init(){
	memset(par,-1,sizeof(par));
	dfs_lca(0,0,0);
	for(int k=0;k<55-1;k++){
		for(int i=0;i<n;i++){
			if(par[k][i]==-1){
				par[k+1][i]=-1;
			}
			else{
				par[k+1][i]=par[k][par[k][i]];
			}
		}
	}
}

int LCA(int u,int v){
	if(dep[u]<dep[v])swap(u,v);
	for(int i=0;i<55-1;i++){
		if((dep[u]-dep[v])&(1<<i))u=par[i][u];
	}
	if(u==v)return u;
	for(int i=55-1;i>=0;i--){
		if(par[i][u]!=par[i][v]){
			u=par[i][u];
			v=par[i][v];
		}
	}
	return par[0][u];
}

int dfs(int x,int p){
	int res=sum[x];
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first==p)continue;
		ans[vec[x][i].second]=dfs(vec[x][i].first,x);
		res+=ans[vec[x][i].second];
	}
	return res;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(make_pair(b,i));
		vec[b].push_back(make_pair(a,i));
	}
	init();
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--,b--;
		int c=LCA(a,b);
		sum[a]++,sum[b]++,sum[c]-=2;
	}
	dfs(0,-1);
	for(int i=0;i<n-1;i++){
		printf("%d ",ans[i]);
	}puts("");
	return 0;
}


//writer：Sakura
//problem：Fools and Roads
//id：191C/192E
//from：Codeforces
//matrix：another

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bits/stdc++.h>
#define N 100005
using namespace std;

typedef long long ll;

int n;
int dep[N],par[55][N],sum[N],ans[N];
vector<pair<int,int> > vec[N];

void dfs_lca(int x,int p,int d){
	par[0][x]=p;dep[x]=d;
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first!=p)dfs_lca(vec[x][i].first,x,d+1);
	}
}

void init(){
	memset(par,-1,sizeof(par));
	par[0][0]=-1;
	dfs_lca(0,0,0);
	for(int k=0;k<55-1;k++){
		for(int i=0;i<n;i++){
			if(par[k][i]==-1){
				par[k+1][i]=-1;
			}
			else{
				par[k+1][i]=par[k][par[k][i]];
			}
		}
	}
}

int LCA(int u,int v){
	if(dep[u]<dep[v])swap(u,v);
	for(int i=0;i<55-1;i++){
		if((dep[u]-dep[v])&(1<<i))u=par[i][u];
	}
	if(u==v)return u;
	for(int i=55-1;i>=0;i--){
		if(par[i][u]!=par[i][v]){
			u=par[i][u];
			v=par[i][v];
		}
	}
	return par[0][u];
}

int dfs(int x,int p){
	int res=sum[x];
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first==p)continue;
		ans[vec[x][i].second]=dfs(vec[x][i].first,x);
		res+=ans[vec[x][i].second];
	}
	return res;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(make_pair(b,i));
		vec[b].push_back(make_pair(a,i));
	}
	init();
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--,b--;
		int c=LCA(a,b);
		sum[a]++,sum[b]++,sum[c]-=2;
	}
	dfs(0,-1);
	for(int i=0;i<n-1;i++){
		printf("%d ",ans[i]);
	}puts("");
	return 0;
}


//writer：Sakura
//problem：Fools and Roads
//id：191C/192E
//from：Codeforces
//matrix：another

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bits/stdc++.h>
#define N 100005
using namespace std;

typedef long long ll;

int n;
int dep[N],par[22][N],sum[N],ans[N];
vector<pair<int,int> > vec[N];

void dfs_lca(int x,int p,int d){
	par[0][x]=p;dep[x]=d;
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first!=p)dfs_lca(vec[x][i].first,x,d+1);
	}
}

void init(){
	memset(par,-1,sizeof(par));
	dfs_lca(0,0,0);
	for(int k=0;k<22-1;k++){
		for(int i=0;i<n;i++){
			if(par[k][i]==-1){
				par[k+1][i]=-1;
			}
			else{
				par[k+1][i]=par[k][par[k][i]];
			}
		}
	}
}

int LCA(int u,int v){
	if(dep[u]<dep[v])swap(u,v);
	for(int i=0;i<22-1;i++){
		if((dep[u]-dep[v])&(1<<i))u=par[i][u];
	}
	if(u==v)return u;
	for(int i=22-1;i>=0;i--){
		if(par[i][u]!=par[i][v]){
			u=par[i][u];
			v=par[i][v];
		}
	}
	return par[0][u];
}

int dfs(int x,int p){
	int res=sum[x];
	for(int i=0;i<vec[x].size();i++){
		if(vec[x][i].first==p)continue;
		ans[vec[x][i].second]=dfs(vec[x][i].first,x);
		res+=ans[vec[x][i].second];
	}
	return res;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(make_pair(b,i));
		vec[b].push_back(make_pair(a,i));
	}
	init();
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--,b--;
		int c=LCA(a,b);
		sum[a]++,sum[b]++,sum[c]-=2;
	}
	dfs(0,-1);
	for(int i=0;i<n-1;i++){
		printf("%d ",ans[i]);
	}puts("");
	return 0;
}


// 2012-05-28
// LCA
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
typedef long long LL;
using namespace std;
#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define CLR(s) memset(s,0,sizeof(s))

const int N  = 500010;
const int LV = 20; // log_2(N)
int n;

// w[] : label
int E, st[N],w[N],to[N],nt[N],lab[N];
void addedge(int x,int y,int ww,int l){
        nt[E]=st[x]; to[E]=y; w[E]=ww; lab[E]=l; st[x]=E++;
}

int t,r[N],fi[N],ta[N][LV];
LL d[N];

void dfs(int x,int y,LL dist,int dep){
        d[x] = dist;
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i] == y) continue;
                r[t++]=to[i];
                dfs(to[i], x, dist+w[i], dep+1);
                //dfs(to[i], x, dist+1, dep+1);
                r[t++]=x;
        }
}

int lca(int x,int y){ // return real index
        if (fi[x]>fi[y]) swap(x,y);
        int len = fi[y]-fi[x]+1, k=0;
        while ((1<<(k+1))<=len) k++;
        int tx=ta[fi[x]][k], ty=ta[fi[y]-(1<<k)+1][k];
        return (d[tx]<d[ty])?tx:ty;
}

int cnt[N]; // ancestor.
int ans[N]; // output answer

int go(int x, int y) {
        int ret = cnt[x];
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i]==y) continue;
                int ad = go(to[i], x);
                //ans[w[i]] += ad;
                ans[lab[i]] += ad;
                ret += ad;
        }
        return ret;
}

void ComputeLca() {
        d[0]=0;
        t=0; r[t++]=0;
        dfs(0,-1,0,0);

        for (int i=t-1; i>=0; i--) fi[r[i]]=i;
        FOR(i,0,t) ta[i][0]=r[i];
        for (int k=1; k<LV; k++){
                FOR(i,0,t){
                        if (i+(1<<k)>t) break;
                        int x=ta[i][k-1], y=ta[i+(1<<(k-1))][k-1];
                        ta[i][k]=(d[x]<d[y])?x:y;
                }
        }
}

int main() {
        while (scanf("%d",&n)!=EOF){
                E=0; memset(st,-1,sizeof(st));
                FOR(i,0,n-1){
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        addedge(x,y,1,i);
                        addedge(y,x,1,i);
                }

                ComputeLca();

                // int ancestor = lca(x, y);

                CLR(ans);
                CLR(cnt);
                int m; scanf("%d",&m);

                FOR(tt,0,m){
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        int mid = lca(x,y);
                        cnt[x]++;
                        cnt[y]++;
                        cnt[mid]-=2;
                }

                go(0, -1);
                FOR(i,0,n-1) printf("%d%c", ans[i],i==n-2?'\n':' ');
        }
        return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
typedef long long LL;
using namespace std;
#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define CLR(s) memset(s,0,sizeof(s))

///////////////////////////////////////////////////////////
//
const int N  = 500010;
const int LV = 20; // log_2(N)
int n;

// lab[] : label
// w[]   : edge-weight
int E, st[N],w[N],to[N],nt[N],lab[N];
void addedge(int x,int y,int ww,int l){
        nt[E]=st[x]; to[E]=y; w[E]=ww; lab[E]=l; st[x]=E++;
}

int t,r[N],fi[N],ta[N][LV];
LL d[N];

void dfs(int x,int y,LL dist,int dep){
        d[x] = dist;
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i] == y) continue;
                r[t++]=to[i];
                dfs(to[i], x, dist+w[i], dep+1);
                r[t++]=x;
        }
}

int lca(int x,int y){ // return real index
        if (fi[x]>fi[y]) swap(x,y);
        int len = fi[y]-fi[x]+1, k=0;
        while ((1<<(k+1))<=len) k++;
        int tx=ta[fi[x]][k], ty=ta[fi[y]-(1<<k)+1][k];
        return (d[tx]<d[ty])?tx:ty;
}

void Init() {
        E=0; memset(st,-1,sizeof(st));
}

void ComputeLca(int root=-1) {
        if (root==-1) root = 0;
        d[root]=0;
        t=0; r[t++]=0;
        dfs(root,-1,0,0);

        for (int i=t-1; i>=0; i--) fi[r[i]]=i;
        FOR(i,0,t) ta[i][0]=r[i];
        for (int k=1; k<LV; k++){
                FOR(i,0,t){
                        if (i+(1<<k)>t) break;
                        int x=ta[i][k-1], y=ta[i+(1<<(k-1))][k-1];
                        ta[i][k]=(d[x]<d[y])?x:y;
                }
        }
}
//
//////////////////////////////////////////////////////

int cnt[N]; // ancestor.
int ans[N]; // output answer

int go(int x, int y) {
        int ret = cnt[x];
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i]==y) continue;
                int ad = go(to[i], x);
                //ans[w[i]] += ad;
                ans[lab[i]] += ad;
                ret += ad;
        }
        return ret;
}

int main() {
        while (scanf("%d",&n)!=EOF){
                /////////////////////////////////////////////
                //
                Init();
                FOR(i,0,n-1){
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        addedge(x,y,1,i);
                        addedge(y,x,1,i);
                }
                ComputeLca();
                //
                /////////////////////////////////////////////

                // int ancestor = lca(x, y);

                CLR(ans);
                CLR(cnt);
                int m; scanf("%d",&m);

                FOR(tt,0,m){
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        int mid = lca(x,y);
                        cnt[x]++;
                        cnt[y]++;
                        cnt[mid]-=2;
                }

                go(0, -1);
                FOR(i,0,n-1) printf("%d%c", ans[i],i==n-2?'\n':' ');
        }
        return 0;
}


// 2012-05-28
// LCA
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
typedef long long LL;
using namespace std;
#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define CLR(s) memset(s,0,sizeof(s))

const int N = 500010;

int n;

// w[] : label
int E, st[N],w[N],to[N],nt[N],lab[N];
void addedge(int x,int y,int ww,int l){
        nt[E]=st[x]; to[E]=y; w[E]=ww; lab[E]=l; st[x]=E++;
}

int t,r[N],fi[N],ta[N][20];
LL d[N];

void dfs(int x,int y,LL dist,int dep){
        d[x] = dist;
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i] == y) continue;
                r[t++]=to[i];
                dfs(to[i], x, dist+w[i], dep+1);
                //dfs(to[i], x, dist+1, dep+1);
                r[t++]=x;
        }
}

int lca(int x,int y){
        if (fi[x]>fi[y]) swap(x,y);
        int len = fi[y]-fi[x]+1, k=0;
        while ((1<<(k+1))<=len) k++;
        int tx=ta[fi[x]][k], ty=ta[fi[y]-(1<<k)+1][k];
        //return (d[tx]<d[ty])?tx:ty;
        int ret=(d[tx]<d[ty])?tx:ty;
        return ret;
//      return fi[ret];
}

int cnt[N]; // ancestor.
int ans[N]; // output answer

int go(int x, int y) {
        int ret = cnt[x];
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i]==y) continue;
                int ad = go(to[i], x);
                //ans[w[i]] += ad;
                ans[lab[i]] += ad;
                ret += ad;
        }
        return ret;
}

void ComputeLca() {
        d[0]=0;
        t=0; r[t++]=0;
        dfs(0,-1,0,0);

        for (int i=t-1; i>=0; i--) fi[r[i]]=i;
        FOR(i,0,t) ta[i][0]=r[i];
        for (int k=1; k<20; k++){
                FOR(i,0,t){
                        if (i+(1<<k)>t) break;
                        int x=ta[i][k-1], y=ta[i+(1<<(k-1))][k-1];
                        ta[i][k]=(d[x]<d[y])?x:y;
                }
        }
}

int main() {
        while (scanf("%d",&n)!=EOF){
                E=0; memset(st,-1,sizeof(st));
                FOR(i,0,n-1){
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        addedge(x,y,1,i);
                        addedge(y,x,1,i);
                }

                ComputeLca();

                CLR(ans);
                CLR(cnt);
                int m; scanf("%d",&m);

                FOR(tt,0,m){
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        int mid = lca(x,y);
                        cnt[x]++;
                        cnt[y]++;
                        cnt[mid]-=2;
                }

                go(0, -1);
                FOR(i,0,n-1) printf("%d%c", ans[i],i==n-2?'\n':' ');
        }
        return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
typedef long long LL;
using namespace std;
#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define CLR(s) memset(s,0,sizeof(s))

const int N = 500010;

int n;

// w[] : label
int E, st[N],w[N],to[N],nt[N];
void addedge(int x,int y,int ww){
        nt[E]=st[x]; to[E]=y; w[E]=ww; st[x]=E++;
}

int t,r[N],fi[N],ta[N][20];
LL d[N];

void dfs(int x,int y,LL dist,int dep){
        d[x] = dist;
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i] == y) continue;
                r[t++]=to[i];
                //dfs(to[i], x, dist+w[i], dep+1);
                dfs(to[i], x, dist+1, dep+1);
                r[t++]=x;
        }
}

int lca(int x,int y){
        if (fi[x]>fi[y]) swap(x,y);
        int len = fi[y]-fi[x]+1, k=0;
        while ((1<<(k+1))<=len) k++;
        int tx=ta[fi[x]][k], ty=ta[fi[y]-(1<<k)+1][k];
        //return (d[tx]<d[ty])?tx:ty;
        int ret=(d[tx]<d[ty])?tx:ty;
        return ret;
//      return fi[ret];
}

int cnt[N]; // ancestor.
int ans[N]; // output answer

int go(int x, int y) {
        int ret = cnt[x];
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i]==y) continue;
                int ad = go(to[i], x);
                ans[w[i]] += ad;
                ret += ad;
        }
        return ret;
}

int main() {
        while (scanf("%d",&n)!=EOF){
                E=0; memset(st,-1,sizeof(st));
                FOR(i,0,n-1){
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        addedge(x,y,i);
                        addedge(y,x,i);
                }
                d[0]=0;
                t=0; r[t++]=0;
                dfs(0,-1,0,0);

                for (int i=t-1; i>=0; i--) fi[r[i]]=i;
                FOR(i,0,t) ta[i][0]=r[i];
                for (int k=1; k<20; k++){
                        FOR(i,0,t){
                                if (i+(1<<k)>t) break;
                                int x=ta[i][k-1], y=ta[i+(1<<(k-1))][k-1];
                                ta[i][k]=(d[x]<d[y])?x:y;
                        }
                }

                CLR(ans);
                CLR(cnt);
                int m; scanf("%d",&m);

//              FOR(i,0,t) printf("%d: %d\n", i, r[i]+1);
//              puts("~~~");
                FOR(tt,0,m){
//                      if (tt) printf(" ");
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        int mid = lca(x,y);
                        cnt[x]++;
                        cnt[y]++;
                        cnt[mid]-=2;
//                      printf("{%d %d} = %d\n", x+1, y+1, mid);
                }
                go(0, -1);
                FOR(i,0,n-1) printf("%d%c", ans[i],i==n-2?'\n':' ');
        }
        return 0;
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cctype>
#include <numeric>
#include <queue>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <iterator>
#define FOR(i,s,e) for(int i=(s);i<(int)(e);i++)
#define FOE(i,s,e) for(int i=(s);i<=(int)(e);i++)
#define REP(i,n)   FOR(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define CLR(s) memset(s,0,sizeof(s))
#define PB push_back
#define ITER(v)      __typeof((v).begin())
#define FOREACH(i,v) for(ITER(v) i=(v).begin();i!=(v).end();i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> vi;
#define x first
#define y second

///////////////////////////////////////////////////////////
//
const int N  = 500010;
const int LV = 20; // log_2(N)
int n;

// lab[] : label
// w[]   : edge-weight
int E, st[N],w[N],to[N],nt[N],lab[N];
void addedge(int x,int y,int ww,int l){
        nt[E]=st[x]; to[E]=y; w[E]=ww; lab[E]=l; st[x]=E++;
}

int t,r[N],fi[N],ta[N][LV];
LL d[N];

void dfs(int x,int y,LL dist,int dep){
        d[x] = dist;
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i] == y) continue;
                r[t++]=to[i];
                dfs(to[i], x, dist+w[i], dep+1);
                r[t++]=x;
        }
}

int lca(int x,int y){ // return real index
        if (fi[x]>fi[y]) swap(x,y);
        int len = fi[y]-fi[x]+1, k=0;
        while ((1<<(k+1))<=len) k++;
        int tx=ta[fi[x]][k], ty=ta[fi[y]-(1<<k)+1][k];
        return (d[tx]<d[ty])?tx:ty;
}

void Init() {
        E=0; memset(st,-1,sizeof(st));
}

void ComputeLca(int root=-1) {
        if (root==-1) root = 0;
        d[root]=0;
        t=0; r[t++]=0;
        dfs(root,-1,0,0);

        for (int i=t-1; i>=0; i--) fi[r[i]]=i;
        FOR(i,0,t) ta[i][0]=r[i];
        for (int k=1; k<LV; k++){
                FOR(i,0,t){
                        if (i+(1<<k)>t) break;
                        int x=ta[i][k-1], y=ta[i+(1<<(k-1))][k-1];
                        ta[i][k]=(d[x]<d[y])?x:y;
                }
        }
}
//
//////////////////////////////////////////////////////

int cnt[N]; // ancestor.
int ans[N]; // output answer

int go(int x, int y) {
        int ret = cnt[x];
        for (int i=st[x]; i!=-1; i=nt[i]){
                if (to[i]==y) continue;
                int ad = go(to[i], x);
                //ans[w[i]] += ad;
                ans[lab[i]] += ad;
                ret += ad;
        }
        return ret;
}

int main() {
        while (scanf("%d",&n)!=EOF){
                /////////////////////////////////////////////
                //
                Init();
                FOR(i,0,n-1){
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        addedge(x,y,1,i);
                        addedge(y,x,1,i);
                }
                ComputeLca();
                //
                /////////////////////////////////////////////

                // int ancestor = lca(x, y);

                CLR(ans);
                CLR(cnt);
                int m; scanf("%d",&m);

                FOR(tt,0,m){
                        int x,y; scanf("%d%d",&x,&y); --x; --y;
                        int mid = lca(x,y);
                        cnt[x]++;
                        cnt[y]++;
                        cnt[mid]-=2;
                }

                go(0, -1);
                FOR(i,0,n-1) printf("%d%c", ans[i],i==n-2?'\n':' ');
        }
        return 0;
}


#include <bits/stdc++.h>
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define ll long long
const int mod = 998244353;
inline void update(int &x, int y) { x += y; if(x >= mod) x -= mod; }
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
const int N = 2e5 + 10;
int p, Dep;
int n, dep[N], f[N], fa[N][20], sz[N], u[N], v[N], sum[N];
vector<int> a[N];

void dfs(int x, int f)
{
    dep[x] = dep[f] + 1;
    Dep = max(Dep, dep[x]);
    sz[x] = 1;
    fa[x][0] = f;
    int nn = a[x].size();
    rep(i, 0, nn - 1)
    {
        int to = a[x][i];
        if(to == f) continue;
        dfs(to, x);
        sz[x] += sz[to];
    }
}

int lca(int u, int v)
{
	if(u == v) return u;
	if(dep[u] > dep[v]) swap(u, v);
	int len = dep[v] - dep[u];
	rrep(i, Dep, 0)
	{
	    int l = 1 << i;
        if(l > len) continue;
        len -= l;
        v = fa[v][i];
	}
	if(u == v) return u;
	rrep(i, Dep, 0)
	{
        if(fa[u][i] == fa[v][i]) continue;
        u = fa[u][i];
        v = fa[v][i];
	}
	return fa[u][0];
}

void dfs1(int x, int fa)
{
	sum[x] = f[x];
	int nn = a[x].size();
	rep(i, 0, nn - 1)
	{
		int to = a[x][i];
		if(to == fa) continue;
		dfs1(to, x);
		sum[x] += sum[to];
	}
}

int main()
{
	n = read();
	rep(i, 1, n - 1)
	{
		u[i] = read();
		v[i] = read();
		a[u[i]].pb(v[i]);
		a[v[i]].pb(u[i]);

	}
	dfs(1, 0);
	while((1 << p) <= Dep) p ++;
	rep(i, 1, Dep)
        rep(j, 1, n)
            fa[j][i] = fa[fa[j][i - 1]][i - 1];
	int Q = read();
	while(Q --)
	{
		int u, v;
		u = read();
		v = read();
		f[u] ++;
		f[v] ++;
       // cout << lca(u, v) << endl;
		f[lca(u, v)] -= 2;
	}

	dfs1(1, 0);
	rep(i, 1, n - 1)
	{
		int x = u[i];
		int y = v[i];
		if(dep[x] < dep[y]) printf("%d ", sum[y]);
		else printf("%d ", sum[x]);
	}

	return 0;
}


#include <bits/stdc++.h>
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define ll long long
const int mod = 998244353;
inline void update(int &x, int y) { x += y; if(x >= mod) x -= mod; }
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
const int N = 2e5 + 10;
int n, dep[N], f[N], fa[N][20], sz[N], u[N], v[N], sum[N];
vector<int> a[N];

void dfs(int x, int f)
{
    dep[x] = dep[f] + 1;
    sz[x] = 1;
    fa[x][0] = f;
    int nn = a[x].size();
    rep(i, 0, nn - 1)
    {
        int to = a[x][i];
        if(to == f) continue;
        dfs(to, x);
        sz[x] += sz[to];
    }
}

int lca(int u, int v)
{
	if(u == v) return u;
	if(dep[u] > dep[v]) swap(u, v);
	int len = dep[v] - dep[u];
	rrep(i, 16, 0)
	{
	    int l = 1 << i;
        if(l > len) continue;
        len -= l;
        v = fa[v][i];
	}
	if(u == v) return u;
	rrep(i, 16, 0)
	{
        if(fa[u][i] == fa[v][i]) continue;
        u = fa[u][i];
        v = fa[v][i];
	}
	return fa[u][0];
}

void dfs1(int x, int fa)
{
	sum[x] = f[x];
	int nn = a[x].size();
	rep(i, 0, nn - 1)
	{
		int to = a[x][i];
		if(to == fa) continue;
		dfs1(to, x);
		sum[x] += sum[to];
	}
}

int main()
{
	n = read();
	rep(i, 1, n - 1)
	{
		u[i] = read();
		v[i] = read();
		a[u[i]].pb(v[i]);
		a[v[i]].pb(u[i]);

	}
	dfs(1, 0);
	rep(i, 1, 16)
        rep(j, 1, n)
            fa[j][i] = fa[fa[j][i - 1]][i - 1];
	int Q = read();
	while(Q --)
	{
		int u, v;
		u = read();
		v = read();
		f[u] ++;
		f[v] ++;
       // cout << lca(u, v) << endl;
		f[lca(u, v)] -= 2;
	}

	dfs1(1, 0);
	rep(i, 1, n - 1)
	{
		int x = u[i];
		int y = v[i];
		if(dep[x] < dep[y]) printf("%d ", sum[y]);
		else printf("%d ", sum[x]);
	}

	return 0;
}


#include <bits/stdc++.h>
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define ll long long
const int mod = 998244353;
inline void update(int &x, int y) { x += y; if(x >= mod) x -= mod; }
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
const int N = 2e5 + 10;
int n, son[N], dep[N], f[N], idx[N], timer, fa[N], sz[N], top[N], u[N], v[N], sum[N];
vector<int> a[N];

void dfs(int x, int f)
{
	fa[x] = f;
	sz[x] = 1;
	dep[x] = dep[f] + 1;
	int nn = a[x].size();
	rep(i, 0, nn - 1)
	{
		int to = a[x][i];
		if(to == f) continue;
		dfs(to, x);
		sz[x] += sz[to];
		if(son[x] == 0) {son[x] = to; continue;}
		if(sz[to] > sz[son[x]]) son[x] = to;
	}
}

void dfs(int x, int fa, int Top)
{
	top[x] = Top;
	idx[x] = ++ timer;
	if(son[x]) dfs(son[x], x, Top);
	int nn = a[x].size();
	rep(i, 0, nn - 1)
	{
		int to = a[x][i];
		if(to == fa || to == son[x]) continue;
		dfs(to, x, to);
	}
}

int lca(int u, int v)
{
	int x = top[u], y = top[v];
	while(x != y)
	{
		if(dep[x] < dep[y])
		{
			swap(x, y);
			swap(u, v);
		}
		u = fa[x];
		x = top[u];
	}
	if(u == v) return u;
	if(dep[u] < dep[v]) return u;
	return v;
}

void dfs1(int x, int fa)
{
	sum[x] = f[x];
	int nn = a[x].size();
	rep(i, 0, nn - 1)
	{
		int to = a[x][i];
		if(to == fa) continue;
		dfs1(to, x);
		sum[x] += sum[to];
	}
}

int main()
{
	n = read();
	rep(i, 1, n - 1)
	{
		u[i] = read();
		v[i] = read();
		a[u[i]].pb(v[i]);
		a[v[i]].pb(u[i]);

	}
	dfs(1, 0);
	dfs(1, 0, 1);
	int Q = read();
	while(Q --)
	{
		int u, v;
		u = read();
		v = read();
		f[u] ++;
		f[v] ++;
       // cout << lca(u, v) << endl;
		f[lca(u, v)] -= 2;
	}

	dfs1(1, 0);
	rep(i, 1, n - 1)
	{
		int x = u[i];
		int y = v[i];
		if(dep[x] < dep[y]) printf("%d ", sum[y]);
		else printf("%d ", sum[x]);
	}

	return 0;
}


#include <bits/stdc++.h>
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define ll long long
const int mod = 998244353;
inline void update(int &x, int y) { x += y; if(x >= mod) x -= mod; }
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
const int N = 2e5 + 10;
int p, Dep;
int n, dep[N], f[N], fa[N][20], sz[N], u[N], v[N], sum[N];
vector<int> a[N];

void dfs(int x, int f)
{
    dep[x] = dep[f] + 1;
    Dep = max(Dep, dep[x]);
    sz[x] = 1;
    fa[x][0] = f;
    int nn = a[x].size();
    rep(i, 0, nn - 1)
    {
        int to = a[x][i];
        if(to == f) continue;
        dfs(to, x);
        sz[x] += sz[to];
    }
}

int lca(int u, int v)
{
	if(u == v) return u;
	if(dep[u] > dep[v]) swap(u, v);
	int len = dep[v] - dep[u];
	rrep(i, p, 0)
	{
	    int l = 1 << i;
        if(l > len) continue;
        len -= l;
        v = fa[v][i];
	}
	if(u == v) return u;
	rrep(i, p, 0)
	{
        if(fa[u][i] == fa[v][i]) continue;
        u = fa[u][i];
        v = fa[v][i];
	}
	return fa[u][0];
}

void dfs1(int x, int fa)
{
	sum[x] = f[x];
	int nn = a[x].size();
	rep(i, 0, nn - 1)
	{
		int to = a[x][i];
		if(to == fa) continue;
		dfs1(to, x);
		sum[x] += sum[to];
	}
}

int main()
{
	n = read();
	rep(i, 1, n - 1)
	{
		u[i] = read();
		v[i] = read();
		a[u[i]].pb(v[i]);
		a[v[i]].pb(u[i]);

	}
	dfs(1, 0);
	while((1 << p) <= Dep) p ++;
	rep(i, 1, p)
        rep(j, 1, n)
            fa[j][i] = fa[fa[j][i - 1]][i - 1];
	int Q = read();
	while(Q --)
	{
		int u, v;
		u = read();
		v = read();
		f[u] ++;
		f[v] ++;
       // cout << lca(u, v) << endl;
		f[lca(u, v)] -= 2;
	}

	dfs1(1, 0);
	rep(i, 1, n - 1)
	{
		int x = u[i];
		int y = v[i];
		if(dep[x] < dep[y]) printf("%d ", sum[y]);
		else printf("%d ", sum[x]);
	}

	return 0;
}


#include <bits/stdc++.h>
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define ll long long
const int mod = 998244353;
inline void update(int &x, int y) { x += y; if(x >= mod) x -= mod; }
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
const int N = 2e5 + 10;
int n, dep[N], f[N], fa[N][20], sz[N], u[N], v[N], sum[N];
vector<int> a[N];

void dfs(int x, int f)
{
    dep[x] = dep[f] + 1;
    sz[x] = 1;
    fa[x][0] = f;
    int nn = a[x].size();
    rep(i, 0, nn - 1)
    {
        int to = a[x][i];
        if(to == f) continue;
        dfs(to, x);
        sz[x] += sz[to];
    }
}

int lca(int u, int v)
{
	if(u == v) return u;
	if(dep[u] > dep[v]) swap(u, v);
	int len = dep[v] - dep[u];
	rrep(i, 19, 0)
	{
	    int l = 1 << i;
        if(l > len) continue;
        len -= l;
        v = fa[v][i];
	}
	if(u == v) return u;
	rrep(i, 19, 0)
	{
        if(fa[u][i] == fa[v][i]) continue;
        u = fa[u][i];
        v = fa[v][i];
	}
	return fa[u][0];
}

void dfs1(int x, int fa)
{
	sum[x] = f[x];
	int nn = a[x].size();
	rep(i, 0, nn - 1)
	{
		int to = a[x][i];
		if(to == fa) continue;
		dfs1(to, x);
		sum[x] += sum[to];
	}
}

int main()
{
	n = read();
	rep(i, 1, n - 1)
	{
		u[i] = read();
		v[i] = read();
		a[u[i]].pb(v[i]);
		a[v[i]].pb(u[i]);

	}
	dfs(1, 0);
	rep(i, 1, 19)
        rep(j, 1, n)
            fa[j][i] = fa[fa[j][i - 1]][i - 1];
	int Q = read();
	while(Q --)
	{
		int u, v;
		u = read();
		v = read();
		f[u] ++;
		f[v] ++;
       // cout << lca(u, v) << endl;
		f[lca(u, v)] -= 2;
	}

	dfs1(1, 0);
	rep(i, 1, n - 1)
	{
		int x = u[i];
		int y = v[i];
		if(dep[x] < dep[y]) printf("%d ", sum[y]);
		else printf("%d ", sum[x]);
	}

	return 0;
}


#include <cstdio>
#include <vector>
using namespace std;

const int MAXN = 1e5+10, MAXLG = 20;
vector<int> v[MAXN], ix[MAXN];
int n, dp[MAXN][MAXLG], d[MAXN];
int go[MAXN], l[MAXN];
int resp[MAXN], ixpai[MAXN];

void dfsLCA(int i, int last, int idx){
    dp[i][0] = last;
    ixpai[i] = idx;

    for (int k=0;k<(int)v[i].size();k++)
    if (dp[v[i][k]][0] == 0){
        d[v[i][k]] = d[i] + 1;
            dfsLCA(v[i][k], i, ix[i][k]);
    }
}

void mkLCA(){
    dfsLCA(1, 1, 0);

    for(int i=0;i<MAXLG;i++)
    dp[1][i] = 1;

    for (int i=1;i<MAXLG;i++)
    for(int k=2;k<=n;k++)
        dp[k][i] = dp[dp[k][i-1]][i-1];
}

void findLCA(int ia, int ib){
    if (d[ia] < d[ib]) swap(ia, ib);

    int log;
    for (log = 1; 1 << log <= d[ia];)log++;

    int a = ia, b = ib;

    for (int i=log;i>=0 && d[a] != d[b];i--){
//  printf("i: %d ", i);
//  printf("depth a %d b %d\n", d[a], d[b]);
//  printf("dp %d depth %d\n", dp[a][i], d[dp[a][i]]);
    if (d[dp[a][i]] >= d[b])
        a = dp[a][i];
    }
//    printf("end: ");
//    printf("depth a %d b %d\n", d[a], d[b]);

    for (int i=log;i>=0 && a != b;i--){
//  printf("i: %d ", i);
//  printf("jumping a %d b %d\n", a, b);
    if(dp[a][i] != dp[b][i]){
        a = dp[a][i];
        b = dp[b][i];
    }
    }
//    printf("end: ");
//    printf("jumping a %d b %d\n", a, b);

    while (a != b){
//  printf("while\n");
    a = dp[a][0];
    b = dp[b][0];
    }

//    printf("LCA %d %d == %d\n", ia, ib, a);
    l[a]++;
    go[ia]++;
    go[ib]++;
}

bool ok[MAXN];
int findRESP(int i){
    ok[i] = 1;
    int sum = go[i];
    for (int k=0;k<(int)v[i].size();k++){
    if(ok[v[i][k]]) continue;
    else{
        sum += findRESP(v[i][k]);
    }
    }

//    printf("i: %d l %d go %d sum %d sum-l*s %d\n", i, l[i], go[i], sum, sum-l[i]*2);

    return resp[ixpai[i]] = sum - l[i]*2;
}

int main(){
    int m;
    scanf("%d", &n);
    for (int i=1,a,b;i<n;i++){
    scanf("%d %d",&a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
    ix[a].push_back(i);
    ix[b].push_back(i);
    }

    mkLCA();

    scanf("%d", &m);
    for (int i=1,a,b;i<=m;i++){
    scanf("%d %d", &a, &b);
    findLCA(a,b);
    }

    findRESP(1);
    for (int i=1;i<n;i++)
    printf("%d ", resp[i]);
    printf("\n");
}


#include <cstdio>
#include <vector>
using namespace std;

const int MAXN = 1e5+10, MAXLG = 20;
vector<int> v[MAXN], ix[MAXN];
int n, dp[MAXN][MAXLG], d[MAXN];
int go[MAXN], l[MAXN];
int resp[MAXN], ixpai[MAXN];

void dfsLCA(int i, int last, int idx){
    dp[i][0] = last;
    ixpai[i] = idx;

    for (int k=0;k<(int)v[i].size();k++)
	if (dp[v[i][k]][0] == 0){
	    d[v[i][k]] = d[i] + 1;
            dfsLCA(v[i][k], i, ix[i][k]);
	}
}

void mkLCA(){
    dfsLCA(1, 1, 0);

    for(int i=0;i<MAXLG;i++)
	dp[1][i] = 1;

    for (int i=1;i<MAXLG;i++)
	for(int k=2;k<=n;k++)
	    dp[k][i] = dp[dp[k][i-1]][i-1];
}

void findLCA(int ia, int ib){
    if (d[ia] < d[ib]) swap(ia, ib);

    int log;
    for (log = 1; 1 << log <= d[ia];)log++;

    int a = ia, b = ib;

    for (int i=log;i>=0 && d[a] != d[b];i--){
//	printf("i: %d ", i);
//	printf("depth a %d b %d\n", d[a], d[b]);
//	printf("dp %d depth %d\n", dp[a][i], d[dp[a][i]]);
	if (d[dp[a][i]] >= d[b])
	    a = dp[a][i];
    }
//    printf("end: ");
//    printf("depth a %d b %d\n", d[a], d[b]);

    for (int i=log;i>=0 && a != b;i--){
//	printf("i: %d ", i);
//	printf("jumping a %d b %d\n", a, b);
	if(dp[a][i] != dp[b][i]){
	    a = dp[a][i];
	    b = dp[b][i];
	}
    }
//    printf("end: ");
//    printf("jumping a %d b %d\n", a, b);

    while (a != b){
//	printf("while\n");
	a = dp[a][0];
	b = dp[b][0];
    }

//    printf("LCA %d %d == %d\n", ia, ib, a);
    l[a]++;
    go[ia]++;
    go[ib]++;
}

bool ok[MAXN];
int findRESP(int i){
    ok[i] = 1;
    int sum = go[i];
    for (int k=0;k<(int)v[i].size();k++){
	if(ok[v[i][k]]) continue;
	else{
	    sum += findRESP(v[i][k]);
	}
    }

//    printf("i: %d l %d go %d sum %d sum-l*s %d\n", i, l[i], go[i], sum, sum-l[i]*2);

    return resp[ixpai[i]] = sum - l[i]*2;
}

int main(){
    int m;
    scanf("%d", &n);
    for (int i=1,a,b;i<n;i++){
	scanf("%d %d",&a, &b);
	v[a].push_back(b);
	v[b].push_back(a);
	ix[a].push_back(i);
	ix[b].push_back(i);
    }

    mkLCA();

    scanf("%d", &m);
    for (int i=1,a,b;i<=m;i++){
	scanf("%d %d", &a, &b);
	findLCA(a,b);
    }

    findRESP(1);
    for (int i=1;i<n;i++)
	printf("%d ", resp[i]);
    printf("\n");
}


#include <cstdio>
#include <vector>
using namespace std;

const int MAXN = 1e5+10, MAXLG = 20;
vector<int> v[MAXN], ix[MAXN];
int n, dp[MAXN][MAXLG], d[MAXN];
int go[MAXN], l[MAXN];
int resp[MAXN], ixpai[MAXN];

void dfsLCA(int i, int last, int idx){
    dp[i][0] = last;
    ixpai[i] = idx;

    for (int k=0;k<(int)v[i].size();k++)
    if (dp[v[i][k]][0] == 0){
        d[v[i][k]] = d[i] + 1;
            dfsLCA(v[i][k], i, ix[i][k]);
    }
}

void mkLCA(){
    dfsLCA(1, 1, 0);

    for(int i=0;i<MAXLG;i++)
    dp[1][i] = 1;

    for (int i=1;i<MAXLG;i++)
    for(int k=1;k<=n;k++)
        dp[k][i] = dp[dp[k][i-1]][i-1];
}

void findLCA(int ia, int ib){
    if (d[ia] < d[ib]) swap(ia, ib);
    int a = ia, b = ib;

    for (int i=MAXLG-1;i>=0 && d[a] != d[b];i--){
    if (d[dp[a][i]] <= d[b])
        a = dp[a][i];
//  printf("depth a %d b %d\n", d[a], d[b]);
    }

//    printf("jumping1 %d %d\n", a, b);
    for (int i=MAXLG-1;i>=0 && a != b;i--){
    if(dp[a][i] != dp[b][i]){
        a = dp[a][i];
        b = dp[b][i];
    }
//  printf("jumping a %d b %d\n", a, b);
    }

    while (a != b){
//  printf("while\n");
    a = dp[a][0];
    b = dp[b][0];
    }

//    printf("LCA %d %d == %d\n", ia, ib, a);
    l[a]++;
    go[ia]++;
    go[ib]++;
}

bool ok[MAXN];
int findRESP(int i){
    ok[i] = 1;
    int sum = go[i];
    for (int k=0;k<(int)v[i].size();k++){
    if(ok[v[i][k]]) continue;
    else{
        sum += findRESP(v[i][k]);
    }
    }

    return resp[ixpai[i]] = sum - l[i]*2;
}

int main(){
    int m;
    scanf("%d", &n);
    for (int i=1,a,b;i<n;i++){
    scanf("%d %d",&a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
    ix[a].push_back(i);
    ix[b].push_back(i);
    }

    mkLCA();

    scanf("%d", &m);
    for (int i=1,a,b;i<=m;i++){
    scanf("%d %d", &a, &b);
    findLCA(a,b);
    }

    findRESP(1);
    for (int i=1;i<n;i++)
    printf("%d ", resp[i]);
    printf("\n");
}


#include <cstdio>
#include <vector>
using namespace std;

const int MAXN = 1e5+10, MAXLG = 20;
vector<int> v[MAXN], ix[MAXN];
int n, dp[MAXN][MAXLG], d[MAXN];
int go[MAXN], l[MAXN];
int resp[MAXN];

void dfsLCA(int i, int last, int){
    dp[i][0] = last;

    for (int k=0;k<v[i].size();k++)
	if (dp[v[i][k]][0] == 0){
	    d[v[i][k]] = d[i] + 1;
            dfsLCA(v[i][k], i, ix[i][k]);
	}
}

void mkLCA(){
    dfsLCA(1, 1);

    for(int i=0;i<MAXLG;i++)
	dp[1][i] = 1;

    for (int i=1;i<MAXLG;i++)
	for(int k=1;k<=n;k++)
	    dp[i][k] = dp[dp[i][k-1]][k-1];
}

void findLCA(int ia, int ib){
    if (d[ia] < d[ib]) swap(ia, ib);
    int a = ia, b = ib;

    for (int i=MAXLG-1;i>=0;i--)
	if (d[dp[a][i]] <= d[b])
	    a = dp[a][i];

    for (int i=MAXLG-1;i>=0 && a!=b;i--){
	if(dp[a][i] == dp[b][i])
	    continue;
	else{
	    a = dp[a][i];
	    b = dp[b][i];
	}
    }

    while (a != b){
	a = dp[a][0];
	b = dp[b][0];
    }

    printf("LCA %d %d == %d\n", ia, ib, a);
    l[a]++;
    go[ia]++;
    go[ib]++;
}

void findRESP(int i){
    int sum = 0;
    for (int k=0;k<v[i].size();k++)

}

int main(){
    scanf("%d %d", &n, &m);
    for (int i=1,a,b;i<n;i++){
	scanf("%d %d",&a, &b);
	v[a].push_back(b);
	v[b].push_back(a);
	ix[a].push_back(i);
	ix[b].push_back(i);
    }

    mkLCA();
    for (int i=1,a,b;i<=m;i++){
	scanf("%d %d", &a, &b);
	findLCA(a,b);
    }

}


#include <cstdio>
#include <vector>
using namespace std;

const int MAXN = 1e5+10, MAXLG = 20;
vector<int> v[MAXN], ix[MAXN];
int n, dp[MAXN][MAXLG], d[MAXN];
int go[MAXN], l[MAXN];
int resp[MAXN], ixpai[MAXN];

void dfsLCA(int i, int last, int idx){
    dp[i][0] = last;
    ixpai[i] = idx;

    for (int k=0;k<(int)v[i].size();k++)
        if (dp[v[i][k]][0] == 0){
            d[v[i][k]] = d[i] + 1;
            dfsLCA(v[i][k], i, ix[i][k]);
        }
}

void mkLCA(){
    dfsLCA(1, 1, 0);

    for(int i=0;i<MAXLG;i++)
        dp[1][i] = 1;

    for (int i=1;i<MAXLG;i++)
        for(int k=2;k<=n;k++)
            dp[k][i] = dp[dp[k][i-1]][i-1];
}

void findLCA(int ia, int ib){
    if (d[ia] < d[ib]) swap(ia, ib);

    int log;
    for (log = 1; 1 << log <= d[ia];)log++;

    int a = ia, b = ib;

    for (int i=log;i>=0 && d[a] != d[b];i--){
//	printf("i: %d ", i);
//	printf("depth a %d b %d\n", d[a], d[b]);
//	printf("dp %d depth %d\n", dp[a][i], d[dp[a][i]]);
        if (d[dp[a][i]] >= d[b])
            a = dp[a][i];
    }
//    printf("end: ");
//    printf("depth a %d b %d\n", d[a], d[b]);

    for (int i=log;i>=0 && a != b;i--){
//	printf("i: %d ", i);
//	printf("jumping a %d b %d\n", a, b);
        if(dp[a][i] != dp[b][i]){
            a = dp[a][i];
            b = dp[b][i];
        }
    }
//    printf("end: ");
//    printf("jumping a %d b %d\n", a, b);

    while (a != b){
//	printf("while\n");
        a = dp[a][0];
        b = dp[b][0];
    }

//    printf("LCA %d %d == %d\n", ia, ib, a);
    l[a]++;
    go[ia]++;
    go[ib]++;
}

bool ok[MAXN];
int findRESP(int i){
    ok[i] = 1;
    int sum = go[i];
    for (int k=0;k<(int)v[i].size();k++){
        if(ok[v[i][k]]) continue;
        else{
            sum += findRESP(v[i][k]);
        }
    }

//    printf("i: %d l %d go %d sum %d sum-l*s %d\n", i, l[i], go[i], sum, sum-l[i]*2);

    return resp[ixpai[i]] = sum - l[i]*2;
}

int main(){
    int m;
    scanf("%d", &n);
    for (int i=1,a,b;i<n;i++){
        scanf("%d %d",&a, &b);
        v[a].push_back(b);
        v[b].push_back(a);
        ix[a].push_back(i);
        ix[b].push_back(i);
    }

    mkLCA();

    scanf("%d", &m);
    for (int i=1,a,b;i<=m;i++){
        scanf("%d %d", &a, &b);
        findLCA(a,b);
    }

    findRESP(1);
    for (int i=1;i<n;i++)
        printf("%d ", resp[i]);
    printf("\n");
}


//#define LOCAL

/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (n____=int(n),i=0;i<n____;++i)
#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i<b____;++i)
#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i>=a____;--i)
#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)

#define ECH(it, A) for (typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define DO(n) while(n--)
#define DO_C(n) int n____ = n; while(n____--)
#define TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)
#define TO_1(i, a, b) int s_=a<b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)
#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i<j;++i,--j)
#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i<=j;++i,--j)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)

#define Rush int T____; RD(T____); DO(T____)
#pragma comment(linker, "/STACK:36777216")
//#pragma GCC optimize ("O2")
#define Ruby system("ruby main.rb")
#define Haskell system("runghc main.hs")
#define Pascal system("fpc main.pas")

typedef long long LL;
typedef double DB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VD;
typedef set<int> SI;
typedef set<string> SS;
typedef set<LL> SL;
typedef set<DB> SD;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef map<LL, int> MLI;
typedef map<DB, int> MDI;
typedef map<int, bool> MIB;
typedef map<string, bool> MSB;
typedef map<LL, bool> MLB;
typedef map<DB, bool> MDB;
typedef pair<int, int> PII;
typedef pair<int, bool> PIB;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef set<PII> SII;
typedef map<PII, int> MPIII;
typedef map<PII, bool> MPIIB;

/** I/O Accelerator **/

/* ... :" We are I/O Accelerator ... Use us at your own risk ;) ... " .. */

template<class T> inline void RD(T &);
template<class T> inline void OT(const T &);

inline int RD(){ int x; RD(x); return x;}
template<class T> inline T& _RD(T &x){ RD(x); return x;}
inline void RC(char &c){scanf(" %c", &c);}
inline void RS(char *s){scanf("%s", s);}

template<class T0, class T1> inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}
template<class T0, class T1, class T2> inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}
template<class T0, class T1, class T2, class T3> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}
template<class T0, class T1> inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}

template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}

template<class T> inline void SRT(T &A){sort(ALL(A));}
template<class T, class C> inline void SRT(T &A, C B){sort(ALL(A), B);}

/** Add - On **/

const int MOD = 1000000007;
const int INF = 10009;
const DB EPS = 1e-2;
const DB OO = 1e15;
const DB PI = 3.14159265358979323846264; //M_PI;

// <<= ` 0. Daily Use .,

template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (b>a) a=b;}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(min(a, b), max(c, d));}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
int Ceil(int x, int y){return (x - 1) / y + 1;}

// <<= ` 1. Bitwise Operation .,
inline bool _1(int x, int i){return x & 1<<i;}
inline bool _1(LL x, int i){return x & 1LL<<i;}
inline LL _1(int i){return 1LL<<i;}
//inline int _1(int i){return 1<<i;}
inline LL _U(int i){return _1(i) - 1;};
//inline int _U(int i){return _1(i) - 1;};

inline int count_bits(int x){
    x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
    x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
    x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
    x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
    x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
    return x;
}

inline int count_bits(LL x){
    x = (x & 0x5555555555555555LL) + ((x & 0xaaaaaaaaaaaaaaaaLL) >> 1);
    x = (x & 0x3333333333333333LL) + ((x & 0xccccccccccccccccLL) >> 2);
    x = (x & 0x0f0f0f0f0f0f0f0fLL) + ((x & 0xf0f0f0f0f0f0f0f0LL) >> 4);
    x = (x & 0x00ff00ff00ff00ffLL) + ((x & 0xff00ff00ff00ff00LL) >> 8);
    x = (x & 0x0000ffff0000ffffLL) + ((x & 0xffff0000ffff0000LL) >> 16);
    x = (x & 0x00000000ffffffffLL) + ((x & 0xffffffff00000000LL) >> 32);
    return x;
}

int reverse_bits(int x){
    x = ((x >> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);
    x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);
    x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);
    x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);
    x = ((x >> 16) & 0x0000ffff) | ((x << 16) & 0xffff0000);
    return x;
}

// <<= ` 2. Modular Arithmetic Basic .,

inline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}
inline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}
inline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}
inline int dff(int a, int b){a -= b; if (a < 0) a  += MOD; return a;}
inline void MUL(int &a, int b){a = (LL)a * b % MOD;}
inline int pdt(int a, int b){return (LL)a * b % MOD;}

inline int pow(int a, int b){
    int c = 1;
    while (b) {
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

template<class T>
inline int pow(T a, int b){
    T c(1);
    while (b) {
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

inline int _I(int b){
    int a = MOD, x1 = 0, x2 = 1, q;
    while (true){
        q = a / b, a %= b;
        if (!a) return (x2 + MOD) % MOD;
        DEC(x1, pdt(q, x2));

        q = b / a, b %= a;
        if (!b) return (x1 + MOD) % MOD;
        DEC(x2, pdt(q, x1));
    }
}

inline void DIV(int &a, int b){MUL(a, _I(b));}
inline int qtt(int a, int b){return pdt(a, _I(b));}

inline int sum(int a, int b, int MOD){
    a += b; if (a >= MOD) a -= MOD;
    return a;
}

inline int phi(int n){
    int res = n;
    for (int i=2;sqr(i)<=n;++i) if (!(n%i)){
        DEC(res, qtt(res, i));
        do{n /= i;} while(!(n%i));
    }
    if (n != 1)
        DEC(res, qtt(res, n));
    return res;
}

// <<= '9. Comutational Geometry .,

struct Po; struct Line; struct Seg;

inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}
inline int sgn(DB x, DB y){return sgn(x - y);}

struct Po{
    DB x, y;
    Po(DB _x = 0, DB _y = 0):x(_x), y(_y){}

    friend istream& operator >>(istream& in, Po &p){return in >> p.x >> p.y;}
    friend ostream& operator <<(ostream& out, Po p){return out << "(" << p.x << ", " << p.y << ")";}

    friend bool operator ==(Po, Po);
    friend bool operator !=(Po, Po);
    friend Po operator +(Po, Po);
    friend Po operator -(Po, Po);
    friend Po operator *(Po, DB);
    friend Po operator /(Po, DB);

    bool operator < (const Po &rhs) const{return sgn(x, rhs.x) < 0 || sgn(x, rhs.x) == 0 && sgn(y, rhs.y) < 0;}
    Po operator-() const{return Po(-x, -y);}
    Po& operator +=(Po rhs){x += rhs.x, y += rhs.y; return *this;}
    Po& operator -=(Po rhs){x -= rhs.x, y -= rhs.y; return *this;}
    Po& operator *=(DB k){x *= k, y *= k; return *this;}
    Po& operator /=(DB k){x /= k, y /= k; return *this;}

    DB length_sqr(){return sqr(x) + sqr(y);}
    DB length(){return sqrt(length_sqr());}

    DB atan(){
        return atan2(y, x);
    }

    void input(){
        scanf("%lf %lf", &x, &y);
    }
};

bool operator ==(Po a, Po b){return sgn(a.x - b.x) == 0 && sgn(a.y - b.y) == 0;}
bool operator !=(Po a, Po b){return sgn(a.x - b.x) != 0 || sgn(a.y - b.y) != 0;}
Po operator +(Po a, Po b){return Po(a.x + b.x, a.y + b.y);}
Po operator -(Po a, Po b){return Po(a.x - b.x, a.y - b.y);}
Po operator *(Po a, DB k){return Po(a.x * k, a.y * k);}
Po operator *(DB k, Po a){return a * k;}
Po operator /(Po a, DB k){return Po(a.x / k, a.y / k);}

struct Line{
    Po a, b;
    Line(Po _a = Po(), Po _b = Po()):a(_a), b(_b){}
    Line(DB x0, DB y0, DB x1, DB y1):a(Po(x0, y0)), b(Po(x1, y1)){}
    Line(Seg);

    friend ostream& operator <<(ostream& out, Line p){return out << p.a << "-" << p.b;}
};

struct Seg{
    Po a, b;
    Seg(Po _a = Po(), Po _b = Po()):a(_a), b(_b){}
    Seg(DB x0, DB y0, DB x1, DB y1):a(Po(x0, y0)), b(Po(x1, y1)){}
    Seg(Line l);

    friend ostream& operator <<(ostream& out, Seg p){return out << p.a << "-" << p.b;}
    DB length(){return (b - a).length();}
};

Line::Line(Seg l):a(l.a), b(l.b){}
Seg::Seg(Line l):a(l.a), b(l.b){}

#define innerProduct dot
#define scalarProduct dot
#define dotProduct dot
#define outerProduct det
#define crossProduct det

inline DB dot(DB x1, DB y1, DB x2, DB y2){return x1 * x2 + y1 * y2;}
inline DB dot(Po a, Po b){return dot(a.x, a.y, b.x, b.y);}
inline DB dot(Po p0, Po p1, Po p2){return dot(p1 - p0, p2 - p0);}
inline DB dot(Line l1, Line l2){return dot(l1.b - l1.a, l2.b - l2.a);}
inline DB det(DB x1, DB y1, DB x2, DB y2){return x1 * y2 - x2 * y1;}
inline DB det(Po a, Po b){return det(a.x, a.y, b.x, b.y);}
inline DB det(Po p0, Po p1, Po p2){return det(p1 - p0, p2 - p0);}
inline DB det(Line l1, Line l2){return det(l1.b - l1.a, l2.b - l2.a);}

template<class T1, class T2> inline DB dist(T1 x, T2 y){return sqrt(dist_sqr(x, y));}

inline DB dist_sqr(Po a, Po b){return sqr(a.x - b.x) + sqr(a.y - b.y);}
inline DB dist_sqr(Po p, Line l){Po v0 = l.b - l.a, v1 = p - l.a; return sqr(fabs(det(v0, v1))) / v0.length_sqr();}
inline DB dist_sqr(Po p, Seg l){
    Po v0 = l.b - l.a, v1 = p - l.a, v2 = p - l.b;
    if (sgn(dot(v0, v1)) * sgn(dot(v0, v2)) <= 0) return dist_sqr(p, Line(l));
    else return min(v1.length_sqr(), v2.length_sqr());
}

inline DB dist_sqr(Line l, Po p){return dist_sqr(p, l);}
inline DB dist_sqr(Seg l, Po p){return dist_sqr(p, l);}

inline DB dist_sqr(Line l1, Line l2){
    if (sgn(det(l1, l2)) != 0) return 0;
    return dist_sqr(l1.a, l2);
}
inline DB dist_sqr(Line l1, Seg l2){
    Po v0 = l1.b - l1.a, v1 = l2.a - l1.a, v2 = l2.b - l1.a; DB c1 = det(v0, v1), c2 = det(v0, v2);
    return sgn(c1) != sgn(c2) ? 0 : sqr(min(fabs(c1), fabs(c2))) / v0.length_sqr();
}

bool isIntersect(Seg l1, Seg l2){

    //if (l1.a == l2.a || l1.a == l2.b || l1.b == l2.a || l1.b == l2.b) return true;

    return
        min(l1.a.x, l1.b.x) <= max(l2.a.x, l2.b.x) &&
        min(l2.a.x, l2.b.x) <= max(l1.a.x, l1.b.x) &&
        min(l1.a.y, l1.b.y) <= max(l2.a.y, l2.b.y) &&
        min(l2.a.y, l2.b.y) <= max(l1.a.y, l1.b.y) &&
    sgn( det(l1.a, l2.a, l2.b) ) * sgn( det(l1.b, l2.a, l2.b) ) <= 0 &&
    sgn( det(l2.a, l1.a, l1.b) ) * sgn( det(l2.b, l1.a, l1.b) ) <= 0;

}

inline DB dist_sqr(Seg l1, Seg l2){
    if (isIntersect(l1, l2)) return 0;
    else return min(dist_sqr(l1.a, l2), dist_sqr(l1.b, l2), dist_sqr(l2.a, l1), dist_sqr(l2.b, l1));
}

inline bool isOnExtremePoint(const Po &p, const Seg &l){
    return p == l.a || p == l.b;
}

inline bool isOnseg(const Po &p, const Seg &l){

    //if (p == l.a || p == l.b) return false;

    return sgn(det(p, l.a, l.b)) == 0 &&
        sgn(l.a.x, p.x) * sgn(l.b.x, p.x) <= 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) <= 0;
}

inline Po intersect(const Line &l1, const Line &l2){
    return l1.a + (l1.b - l1.a) * (det(l2.a, l1.a, l2.b) / det(l2, l1));
}

// perpendicular foot
inline Po intersect(const Po & p, const Line &l){
    return intersect(Line(p, p + Po(l.a.y - l.b.y, l.b.x - l.a.x)), l);
}

inline Po rotate(Po p, DB alpha, Po o = Po()){
    p.x -= o.x, p.y -= o .y;
    return Po(p.x * cos(alpha) - p.y * sin(alpha), p.y * cos(alpha) + p.x * sin(alpha)) + o;
}

// <<= ' A. Random Event ..

inline int rand32(){return (bool(rand() & 1) << 30) | (rand() << 15) + rand();}
inline int random32(int l, int r){return rand32() % (r - l + 1) + l;}
inline int random(int l, int r){return rand() % (r - l + 1) + l;}
int dice(){return rand() % 6;}
bool coin(){return rand() % 2;}

// <<= ' 0. I/O Accelerator interface .,

template<class T> inline void RD(T &x){
    //cin >> x;
    scanf("%d", &x);
    //char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
    //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
}

template<class T> inline void OT(const T &p){
    printf("%d", p);
}

/* .................................................................................................................................. */

const int N = 10009, M = 2 * N;

int l[N], r[N], p[N], w0[N], w1[N], delay[N]; bool rt[N];
// Link-cut tree
int hd[N], nxt[M], a[M], b[M];
// Adjacent list

int n, ans;

#define lx l[x]
#define rx r[x]

// private:

inline void Inc(int x, int d){
    if (x == 0) return;
    w0[x] += d, w1[x] += d, delay[x] += d;
}

inline void Release(int x){
    if (x == 0) return;

    if (delay[x]){
        Inc(lx, delay[x]), Inc(rx, delay[x]);
        delay[x] = 0;
    }
}

inline void Update(int x){
    w1[x] = w0[x] + w1[lx], w1[rx];
}

inline void Set(int l[], int y, int x){
    l[y] = x, p[x] = y;
}

#define z p[y]
inline void Rotate(int x){
    int y = p[x];

    if (!rt[y]) Release(z), Set(y == l[z] ? l : r, z, x);
    else p[x] = z;

    Release(y), Release(x);

    if (x == l[y]) Set(l, y, rx), Set(r, x, y);
    else Set(r, y, lx), Set(l, x, y);

    if (rt[y]) rt[y] = false, rt[x] = true;
    Update(y);
}

inline void Splay(int x){
    while (!rt[x]) Rotate(x);
}

inline int Access(int x){
    int y = 0; do{
        Splay(x), Release(x);
        rt[rx] = true, rt[rx = y] = false, Update(x);
        x = p[y = x];
    } while (x);
    return y;
}

// public:

void Query(int x, int y){
    Access(y), y = 0; do{
        Splay(x); if (!p[x]){
            OT(w1[rx] + w1[y]);
        }
        rt[rx] = true, rt[rx = y] = false, Update(x);
        x = p[y = x];
    } while (x);
}

void Modify(int x, int y, int w){
    Access(y); y = 0; do{
        Splay(x), Release(x); if (!p[x]) Inc(rx, w), Inc(y, w);
        rt[rx] = true, rt[rx = y] = false, Update(x);
        x = p[y = x];
    } while (x);
}

#define v b[i]
inline void dfs(int u = 1){
    for(int i=hd[u];i;i=nxt[i]) if (!p[v]){
        p[v] = u, dfs(v);
    }
}

int main(){

#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif

        FOR_C(i, 2, _RD(n) << 1){
            RD(a[i], b[i]), a[i|1] = b[i], b[i|1] = a[i];
            nxt[i] = hd[a[i]], hd[a[i]] = i; ++i;
            nxt[i] = hd[a[i]], hd[a[i]] = i;
        }

        FLC(rt, true), p[1] = -1, dfs(), p[1] = 0;

        int x, y; DO_C(RD()){
            RD(x, y);
            //cout << x << " " << y << endl;
            Modify(x, y, 1);
            //break;
        }

        FOR(i, 1, n){
            if (i != 1) printf(" ");
            Query(a[i<<1], b[i<<1]);
        }

}