Problem: 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

Solution (in JAVA):

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Ronak Vaghela
 */
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();
    }

    static class TaskE {
        static long INF = (long) 1e12;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = 1;
            while (t-- > 0) {

                int n = in.nextInt();
                int m = in.nextInt();

                long c[] = new long[n];
                long b[] = new long[n];
                long ab = 0;
                for (int i = 0; i < n; i++) {
                    b[i] = in.nextLong();
                    ab += b[i];
                }
                long val = ab;
                for (int i = 0; i < n; i++) {
                    c[i] = in.nextLong();
                    ab -= c[i];
                }
                if (ab != 0) {
                    out.println("NO");
                    out.close();
                    return;
                }

                int source = n + n;
                int sink = n + n + 1;

                TaskE.MaximumFlowGraph g = new TaskE.MaximumFlowGraph(n + n + 2, source, sink);

                for (int i = 0; i < n; i++) {
                    g.addEdge(source, i, b[i]);
                }
                for (int i = 0; i < n; i++) {
                    g.addEdge(i + n, sink, c[i]);
                    g.addEdge(i, i + n, INF / 4);

                }

                for (int j = 0; j < m; j++) {
                    int p = in.nextInt();
                    int q = in.nextInt();
                    g.addEdge(p - 1, q - 1 + n, INF / 4);
                    g.addEdge(q - 1, p - 1 + n, INF / 4);

                }
                long f = g.getFlow(source, sink);

                if (f != val) {
                    out.println("NO");
                    out.close();
                    return;
                }
                long a[][] = new long[n][n];
                for (int i = 0; i < g.e.size(); i++) {
                    if (g.e.get(i).from < n && g.e.get(i).to >= n && g.e.get(i).to < 2 * n) {
                        a[g.e.get(i).from][g.e.get(i).to - n] = g.e.get(i).flow;
                    }
                }
                out.println("YES");
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        out.print(a[i][j] + " ");
                    }
                    out.println();
                }
            }
            out.close();
        }

        static class MaximumFlowGraph {
            final long INF = (long) 1e15;
            public ArrayList<Edge> e = new ArrayList<>();
            long[] dist;
            int[] parEdge;
            int[] first;
            ArrayList<Integer>[] g;
            int source;
            int sink;

            public MaximumFlowGraph(int size, int source, int sink) {
                this.source = source;
                this.sink = sink;
                dist = new long[size];
                parEdge = new int[size];
                first = new int[size];
                g = new ArrayList[size];
                for (int i = 0; i < size; i++)
                    g[i] = new ArrayList<>();
            }

            public void addEdge(int from, int to, long cap) {
                int size = e.size();
                e.add(new Edge(from, to, cap));
                e.add(new Edge(to, from, 0));
                g[from].add(size);
                g[to].add(size + 1);
            }

            private boolean bfs() {
                Arrays.fill(dist, INF);
                dist[source] = 0;
                Queue<Integer> q = new ArrayDeque<>();
                q.add(source);
                while (!q.isEmpty()) {
                    int v = q.poll();
                    for (int j : g[v]) {
                        Edge curr = e.get(j);
                        int to = curr.to;

                        if (curr.isOpen() && dist[to] > dist[v] + 1) {
                            dist[to] = dist[v] + 1;
                            q.add(to);
                            if (to == sink)
                                return true;

                        }

                    }
                }
                return dist[sink] != INF;
            }

            private boolean dfs(int v, int pe) {
                parEdge[v] = pe;
                if (v == sink)
                    return true;
                if (dist[v] >= dist[sink])
                    return false;
                for (; first[v] < g[v].size(); first[v]++) {
                    Edge curr = e.get(g[v].get(first[v]));
                    if (curr.isOpen() && dist[curr.to] == dist[v] + 1 && dfs(curr.to, g[v].get(first[v])))
                        return true;
                }
                return false;
            }

            long pushFlow() {
                long add = INF;
                int v = sink;
                while (v != source) {
                    Edge curr = e.get(parEdge[v]);
                    add = Math.min(add, curr.getLeft());
                    v = curr.from;
                }
                v = sink;
                while (v != source) {
                    int i = parEdge[v];
                    e.get(i).flow += add;
                    e.get(i ^ 1).flow -= add;
                    v = e.get(i).from;
                }
                return add;
            }

            public long getFlow(int source, int sink) {

                this.source = source;
                this.sink = sink;

                long flow = 0;
                while (bfs()) {
                    Arrays.fill(first, 0);
                    while (dfs(source, -1))
                        flow += pushFlow();
                }
                return flow;
            }

            public class Edge {
                public int from;
                public int to;
                public long flow;
                public long cap;

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

                boolean isOpen() {
                    return cap > flow;
                }

                long getLeft() {
                    return cap - flow;
                }

            }

        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int snumChars;
        private InputReader.SpaceCharFilter filter;

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

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}