In the country there are n cities and m bidirectional roads between them. Each city has an army. Army of the i-th city consists of ai soldiers. Now soldiers roam. After roaming each soldier has to either stay in his city or to go to the one of neighboring cities by at moving along at most one road.

Check if is it possible that after roaming there will be exactly bi soldiers in the i-th city.

Input

First line of input consists of two integers n and m (1 ≤ n ≤ 100, 0 ≤ m ≤ 200).

Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 100).

Next line contains n integers b1, b2, ..., bn (0 ≤ bi ≤ 100).

Then m lines follow, each of them consists of two integers p and q (1 ≤ p, q ≤ n, p ≠ q) denoting that there is an undirected road between cities p and q. 

It is guaranteed that there is at most one road between each pair of cities.

Output

If the conditions can not be met output single word "NO".

Otherwise output word "YES" and then n lines, each of them consisting of n integers. Number in the i-th line in the j-th column should denote how many soldiers should road from city i to city j (if i ≠ j) or how many soldiers should stay in city i (if i = j).

If there are several possible answers you may output any of them.

Examples

Input

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


Output

YES
1 0 0 0 
2 0 0 0 
0 5 1 0 
0 0 2 1 


Input

2 0
1 2
2 1


Output

NO
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Collection;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Queue;
import java.io.IOException;

/**
 * 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);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    final int Inf = 0x3f3f3f3f;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt(), M = in.nextInt();
        int[] A = new int[N], B = new int[N];

        MaxFlowNetwork G = new MaxFlowNetwork(2 * N + 2);
        int S = 2 * N, D = 2 * N + 1;

        int sum = 0;
        for (int i = 0; i < N; ++i) {
            A[i] = in.nextInt();
            sum += A[i];
            G.addEdge(S, i, A[i]);
        }
        for (int i = 0; i < N; ++i) {
            B[i] = in.nextInt();
            sum -= B[i];
            G.addEdge(N + i, D, B[i]);

            G.addEdge(i, N + i, Inf);
        }

        if (sum != 0) {
            out.println("NO");
            return;
        }

        while (M-- > 0) {
            int x = in.nextInt() - 1, y = in.nextInt() - 1;
            G.addEdge(x, N + y, Inf);
            G.addEdge(y, N + x, Inf);
        }

        for (int p: A) sum += p;

        long flow = G.getFlow(S, D);
        if (flow != sum) {
            out.println("NO");
        } else {
            out.println("YES");
            int[][] add = new int[N][N];
            MaxFlowNetwork.Edge[] edges = G.getEdges();

            for (MaxFlowNetwork.Edge p: edges) {
                if (p.from < N && N <= p.to && p.to < 2 * N) {
                    add[p.from][p.to - N] = (int) p.flow;
                }
            }

            for (int[] p: add) {
                for (int l: p)
                    out.print("" + l + ' ');
                out.println();
            }
        }
    }
}

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

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

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

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

    public String next() {
        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;
    }

}

class MaxFlowNetwork {
    public static long Inf = 1L << 62;

    public static class Edge implements Cloneable {
        public int from, to;
        public long cap, flow;
        public Edge rev;

        public Edge(int from, int to, long cap, long flow, Edge rev) {
            this.from = from;
            this.to = to;
            this.cap = cap;
            this.flow = flow;
            this.rev = rev;
        }

        public Edge(int from, int to, long cap, long flow) {
            this.from = from;
            this.to = to;
            this.cap = cap;
            this.flow = flow;
        }

        public boolean isSaturated() {
            return flow >= cap;
        }

        public long augumentValue() {
            return cap - flow;
        }

        public Edge clone() {
            return new Edge(from, to, cap, flow, rev);
        }
    }

    private ArrayList<Edge>[] G;
    private Edge[] father;
    private Edge NIL;

    public MaxFlowNetwork(int N) {
        G = new ArrayList[N];
        for (int i = 0; i < N; ++i)
            G[i] = new ArrayList<>();
        father = new Edge[N];
        NIL = new Edge(0, 0, 0, 0);
    }

    public void addEdge(int x, int y, long cap, long flow) {
        Edge add = new Edge(x, y, cap, flow);
        Edge rev = new Edge(y, x, 0, -flow);
        add.rev = rev; rev.rev = add;
        G[x].add(add);
        G[y].add(rev);
    }

    public Edge[] getEdges() {
        int total = 0;
        for (ArrayList<Edge> p: G) total += p.size();
        Edge[] allEdges = new Edge[total];

        int pos = 0;
        for (ArrayList<Edge> p: G)
            for (Edge l: p)
                allEdges[pos++] = l.clone();

        return allEdges;
    }

    public void addEdge(int x, int y, long cap) {
        addEdge(x, y, cap, 0);
    }

    public long getFlow(int S, int D) {
        long flow = 0;
        while (bfs(S, D)) {
            for (Edge p: G[D]) {
                if (p.rev.isSaturated() || father[p.to] == null) continue;
                father[D] = p;
                long fmin = Inf;
                for (int i = D; i != S; i = father[i].to)
                    fmin = Math.min(fmin, father[i].rev.augumentValue());
                if (fmin == 0) continue;
                for (int i = D; i != S; i = father[i].to) {
                    father[i].rev.flow += fmin;
                    father[i].flow -= fmin;
                }
                flow += fmin;
            }
        }
        return flow;
    }

    private boolean bfs(int S, int D) {
        Queue<Integer> Q = new ArrayDeque<>();
        Arrays.fill(father, null);
        father[S] = NIL;
        Q.add(S);
        while (!Q.isEmpty()) {
            int node = Q.poll();
            if (node == D) continue;

            for (Edge p: G[node]) {
                if (!p.isSaturated() && father[p.to] == null) {
                    Q.add(p.to);
                    father[p.to] = p.rev;
                }
            }
        }

        return father[D] != null;
    }
}

