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.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class soldier {
        public void solve(int testNumber, Input in, PrintWriter out) {
            int soldiers = in.nextInt();
            int edges = in.nextInt();
            int[] a = in.nextIntArray(soldiers);
            int[] b = in.nextIntArray(soldiers);
            boolean[][] g = new boolean[soldiers][soldiers];
            for (int i = 0; i < edges; i++) {
                int p = in.nextInt() - 1;
                int q = in.nextInt() - 1;
                g[p][q] = true;
                g[q][p] = true;
            }
            for (int i = 0; i < soldiers; i++) {
                g[i][i] = true;
            }
            int[][] edge = new int[soldiers][soldiers];
            for (int[] e : edge)
                Arrays.fill(e, -1);
            int vertexes = soldiers * 2 + 2;
            int source = vertexes - 2;
            int dest = source + 1;
            FlowGraph flowGraph = new FlowGraph(vertexes);
            for (int i = 0; i < soldiers; i++) {
                flowGraph.addFlowEdge(source, i, a[i]);
                flowGraph.addFlowEdge(i + soldiers, dest, b[i]);
            }
            final int inf = Integer.MAX_VALUE / 2;
            for (int i = 0; i < soldiers; i++)
                for (int j = 0; j < soldiers; j++) {
                    if (g[i][j]) {
                        edge[i][j] = flowGraph.getEdges();
                        flowGraph.addFlowEdge(i, j + soldiers, inf);
                    }
                }
            int flow = flowGraph.maxFlow(source, dest);
            int sum = 0;
            for (int x : b)
                sum += x;
            int sum1 = 0;
            for (int x : a)
                sum1 += x;
            if (sum == flow && flow == sum1) {
                Answers.outYes(out);
                for (int i = 0; i < soldiers; i++) {
                    for (int j = 0; j < soldiers; j++) {
//                    out.print(edge[i][j] + " ");
                        if (edge[i][j] == -1) {
                            out.print("0 ");
                        } else {
                            out.print(flowGraph.getFlows()[edge[i][j]] + " ");
                        }
                    }
                    out.println();
                }
            } else {
                Answers.outNo(out);
            }
        }

    }

    static class FlowGraph {
        int[] to;
        int[] flows;
        int[] capacities;
        int[] next;
        int[] heads;
        int edges;
        final int vertexCount;
        int arraysCapacity;
        IntQueue queue;
        int[] pointers;
        int[] distance;

        public FlowGraph(int vertexCount, int initialCapacity) {
            this.vertexCount = vertexCount;
            heads = new int[vertexCount];
            queue = new IntQueue(vertexCount);

            Arrays.fill(heads, -1);
            edges = 0;
            arraysCapacity = initialCapacity;
            pointers = new int[vertexCount];
            distance = new int[vertexCount];
            to = new int[arraysCapacity];
            flows = new int[arraysCapacity];
            capacities = new int[arraysCapacity];
            next = new int[arraysCapacity];
        }

        public FlowGraph(int vertexCount) {
            this(vertexCount, 10);
        }

        public void addFlowEdge(int from, int to, int capability) {
            addDirectEdge(from, to, capability);
            addDirectEdge(to, from, 0);
        }

        private void addDirectEdge(int from, int to, int capability) {
            enlargeArraysIfNeed();
            this.to[edges] = to;
            flows[edges] = 0;
            capacities[edges] = capability;
            next[edges] = heads[from];
            heads[from] = edges++;
        }

        private void enlargeArraysIfNeed() {
            if (edges < arraysCapacity)
                return;
            arraysCapacity *= 2;
            int[] newTo = new int[arraysCapacity];
            int[] newFlows = new int[arraysCapacity];
            int[] newCapacities = new int[arraysCapacity];
            int[] newNext = new int[arraysCapacity];
            System.arraycopy(to, 0, newTo, 0, to.length);
            System.arraycopy(flows, 0, newFlows, 0, flows.length);
            System.arraycopy(capacities, 0, newCapacities, 0, capacities.length);
            System.arraycopy(next, 0, newNext, 0, next.length);
            to = newTo;
            flows = newFlows;
            capacities = newCapacities;
            next = newNext;
        }

        public int maxFlow(int source, int destination) {
            int totalFlow = 0;
            final int inf = Integer.MAX_VALUE / 2;
            while (bfs(source, destination)) {
                while (true) {
                    System.arraycopy(heads, 0, pointers, 0, pointers.length);
                    int stepFlow = dfs(source, destination, inf);
                    if (stepFlow == 0)
                        break;
                    totalFlow += stepFlow;
                }
            }
            return totalFlow;
        }

        private int dfs(int source, int destination, int flow) {
            if (source == destination || flow == 0)
                return flow;

            for (int e = pointers[source]; e >= 0; e = next[e]) {
                pointers[source] = next[e];
                int enlarge = capacities[e] - flows[e];
                if (enlarge <= 0 || distance[to[e]] != distance[source] + 1)
                    continue;

                int tempFlow = dfs(to[e], destination, Math.min(flow, enlarge));
                if (tempFlow == 0)
                    continue;

                flows[e] += tempFlow;
                flows[e ^ 1] -= tempFlow;
                return tempFlow;
            }
            return 0;

        }

        private boolean bfs(int source, int destination) {
            Arrays.fill(distance, -1);
            queue.enqueue(source);
            distance[source] = 0;
            while (!queue.isEmpty()) {
                int p = queue.poll();
                for (int e = heads[p]; e >= 0; e = next[e]) {
                    if (distance[to[e]] == -1 && flows[e] < capacities[e]) {
                        distance[to[e]] = distance[p] + 1;
                        queue.enqueue(to[e]);
                    }
                }
            }
            return distance[destination] != -1;
        }

        public int getEdges() {
            return edges;
        }

        public int[] getFlows() {
            return flows;
        }

    }

    static class IntQueue {
        private int[] q;
        private int head;
        private int tail;
        private int maxSize;

        public IntQueue(int maxSize) {
            q = new int[maxSize];
            head = tail = 0;
            this.maxSize = maxSize;
        }

        public void enqueue(int value) {
            q[head++] = value;
            if (head == maxSize)
                head = 0;
        }

        public int poll() {
            int res = q[tail];
            if (++tail == maxSize)
                tail = 0;
            return res;
        }

        public boolean isEmpty() {
            return head == tail;
        }

    }

    static interface Answers {
        public static final String YES = "YES";
        public static final String NO = "NO";

        public static void outYes(PrintWriter out) {
            out.println(YES);
        }

        public static void outNo(PrintWriter out) {
            out.println(NO);
        }

    }

    static class Input {
        private StringTokenizer tokenizer = null;
        private BufferedReader reader;

        public Input(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }

        public String nextToken() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(nextLine());
            }
            return tokenizer.nextToken();
        }

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

        public int[] nextIntArray(int n, int add) {
            int[] result = new int[n];
            for (int i = 0; i < n; i++) {
                result[i] = nextInt() + add;
            }
            return result;
        }

        public int[] nextIntArray(int n) {
            return nextIntArray(n, 0);
        }

    }
}

