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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Vadim Semenov
 */
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 {
    public void solve(final int testNumber, final InputReader in, final PrintWriter out) {
        int vertices = in.nextInt();
        int edges = in.nextInt();
        Graph graph = Graph.createFlowGraph(2 * vertices + 2, 2 * (2 * vertices + edges));
        int source = 0;
        int sink = 2 * vertices + 1;
        long sumA = 0;
        long sumB = 0;
        int inf = -1;
        for (int i = 0; i < vertices; ++i) {
            int capacity = in.nextInt();
            graph.addFlowEdge(source, i + 1, capacity);
            sumA += capacity;
            inf = Math.max(inf, capacity);
        }
        for (int i = 0; i < vertices; ++i) {
            int capacity = in.nextInt();
            graph.addFlowEdge(vertices + 1 + i, sink, capacity);
            sumB += capacity;
            inf = Math.max(inf, capacity);
        }
        for (int v = 0; v < vertices; ++v) {
            graph.addFlowEdge(v + 1, v + vertices + 1, inf);
        }
        for (int e = 0; e < edges; ++e) {
            int u = in.nextInt();
            int v = in.nextInt();
            graph.addFlowEdge(u, vertices + v, inf);
            graph.addFlowEdge(v, vertices + u, inf);
        }
        if (sumA != sumB) {
            out.println("NO");
            return;
        }
        long totalFlow = Flow.dinic(graph, 0, 2 * vertices + 1);
        if (totalFlow != sumA) {
            out.println("NO");
            return;
        }
        out.println("YES");
        int[][] output = new int[vertices][vertices];
        for (int v = 1; v <= vertices; ++v) {
            for (int e : graph.getOutgoingEdges(v)) {
                if (graph.flow(e) > 0) {
                    output[v - 1][graph.end(e) - vertices - 1] = (int) graph.flow(e);
                }
            }
        }
        for (int i = 0; i < vertices; ++i) {
            for (int j = 0; j < vertices; ++j) {
                if (j > 0) out.print(' ');
                out.print(output[i][j]);
            }
            out.println();
        }
    }
}

class InputReader {
    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
    }

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

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

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

class Graph {
    protected int verticesCounter;
    protected int edgesCounter;

    int[] begin;
    int[] end;
    int[] firstOutgoing;
    int[] nextOutgoing;
    int[] firstIncoming;
    int[] nextIncoming;
    int[] reversedEdge;

    byte[] flags;
    long[] weights;
    long[] capacities;
    long[] flows;

    private Graph(int verticesCounter, int edgesCapacity) {
        this.verticesCounter = verticesCounter;
        begin = new int[edgesCapacity];
        end = new int[edgesCapacity];
        firstOutgoing = new int[verticesCounter];
        Arrays.fill(firstOutgoing, -1);
        nextOutgoing = new int[edgesCapacity];
        Arrays.fill(nextOutgoing, -1);
    }

    private Graph(int verticesCounter, int edgesCounter, int[] begin, int[] end, int[] firstOutgoing,
                  int[] nextOutgoing, int[] firstIncoming, int[] nextIncoming, int[] reversedEdge,
                  byte[] flags, long[] weights, long[] capacities, long[] flows) {
        this.verticesCounter = verticesCounter;
        this.edgesCounter = edgesCounter;
        this.begin = begin.clone();
        this.end = end.clone();
        this.firstOutgoing = firstOutgoing.clone();
        this.nextOutgoing = nextOutgoing.clone();
        if (firstIncoming != null) {
            this.firstIncoming = firstIncoming.clone();
        }
        if (nextIncoming != null) {
            this.nextIncoming = nextIncoming.clone();
        }
        if (reversedEdge != null) {
            this.reversedEdge = reversedEdge.clone();
        }
        if (flags != null) {
            this.flags = flags.clone();
        }
        if (weights != null) {
            this.weights = weights.clone();
        }
        if (capacities != null) {
            this.capacities = capacities.clone();
        }
        if (flows != null) {
            this.flows = flows.clone();
        }
    }

    public static Graph createFlowGraph(int verticesCounter, int edgesCapacity) {
        Graph returned = new Graph(verticesCounter, edgesCapacity);
        returned.initializeFlows();
        returned.initializeCapacities();
        returned.initializeReversed();
        return returned;
    }

    public Graph clone() {
        return new Graph(verticesCounter, edgesCounter, begin, end, firstOutgoing, nextOutgoing, firstIncoming,
                nextIncoming, reversedEdge, flags, weights, capacities, flows);
    }

    public int addFlowEdge(int beginID, int endID, long capacity) {
        ensureCapacity(edgesCounter + 1);
        int id = edgesCounter;
        edgesCounter++;
        begin[id] = beginID;
        end[id] = endID;
        capacities[id] = capacity;
        flows[id] = 0;
        reversedEdge[id] = addFlowEdge(endID, beginID, 0, id);
        nextOutgoing[id] = firstOutgoing[beginID];
        firstOutgoing[beginID] = id;
        return id;
    }

    public int addFlowEdge(int beginID, int endID, long capacity, int reversedID) {
        ensureCapacity(edgesCounter + 1);
        int id = edgesCounter;
        edgesCounter++;
        begin[id] = beginID;
        end[id] = endID;
        capacities[id] = capacity;
        flows[id] = 0;
        reversedEdge[id] = reversedID;
        nextOutgoing[id] = firstOutgoing[beginID];
        firstOutgoing[beginID] = id;
        return id;
    }

    public int end(int edgeID) {
        return end[edgeID];
    }

    public void pushFlow(int edgeID, long pushed) {
        flows[edgeID] += pushed;
        flows[reversedEdge[edgeID]] -= pushed;
    }

    public long flow(int edgeID) {
        return flows[edgeID];
    }

    public void remove(int edgeID) {
        throw new UnsupportedOperationException();
    }

    public Iterable<Integer> getOutgoingEdges(final int vertex) {
        return new Iterable<Integer>() {
            public Iterator<Integer> iterator() {
                return new EdgeIterator(firstOutgoing[vertex], nextOutgoing);
            }
        };
    }

    private void ensureCapacity(int capacity) {
        if (begin.length < capacity) {
            int oldSize = begin.length;
            int newSize = Math.max(capacity, 2 * begin.length);
            begin = ArrayUtils.resize(begin, newSize);
            end = ArrayUtils.resize(end, newSize);
            nextOutgoing = ArrayUtils.resize(nextOutgoing, newSize);
            Arrays.fill(nextOutgoing, oldSize, nextOutgoing.length, -1);
            if (nextIncoming != null) {
                nextIncoming = ArrayUtils.resize(nextIncoming, newSize);
            }
            if (reversedEdge != null) {
                reversedEdge = ArrayUtils.resize(reversedEdge, newSize);
            }
            if (flags != null) {
                flags = ArrayUtils.resize(flags, newSize);
            }
            if (weights != null) {
                weights = ArrayUtils.resize(weights, newSize);
            }
            if (capacities != null) {
                capacities = ArrayUtils.resize(capacities, newSize);
            }
            if (flows != null) {
                flows = ArrayUtils.resize(flows, newSize);
            }
        }
    }

    private void initializeCapacities() {
        if (capacities == null) {
            capacities = new long[begin.length];
        }
    }

    private void initializeFlows() {
        if (flows == null) {
            flows = new long[begin.length];
        }
    }

    private void initializeReversed() {
        if (reversedEdge == null) {
            reversedEdge = new int[begin.length];
        }
    }

    public final class EdgeIterator implements Iterator<Integer> {
        private int currentID, nextID;
        private int[] nextEdge;

        public EdgeIterator(int nextID, int[] nextEdge) {
            this.currentID = -1;
            this.nextID = nextID;
            this.nextEdge = nextEdge;
        }

        public boolean hasNext() {
            return nextID != -1;
        }

        public Integer next() {
            if (nextID == -1) {
                throw new NoSuchElementException();
            }
            currentID = nextID;
            nextID = nextEdge[currentID];
            return currentID;
        }

        public void remove() {
            if (currentID == -1) {
                throw new IllegalStateException();
            }
            Graph.this.remove(currentID);
        }
    }
}

class Flow {
    private Graph graph;
    private int source;
    private int sink;

    private int[] queue;
    private int[] nextEdge;
    private int[] level;

    private Flow(Graph graph, int source, int sink) {
        this.graph = graph;
        this.source = source;
        this.sink = sink;
        queue = new int[graph.verticesCounter];
        nextEdge = new int[graph.verticesCounter];
        level = new int[graph.verticesCounter];
    }

    public static long dinic(Graph graph, int source, int sink) {
        return new Flow(graph, source, sink).dinic();
    }

    private long dinic() {
        long totalPushed = 0;
        while (bfs()) {
            for (int v = 0; v < graph.verticesCounter; ++v) {
                nextEdge[v] = graph.firstOutgoing[v];
            }
            while (true) {
                long pushed = dfs(source, Long.MAX_VALUE);
                if (pushed == 0) {
                    break;
                }
                totalPushed += pushed;
            }
        }
        return totalPushed;
    }

    private long dfs(int vertex, long minCapacity) {
        if (vertex == sink) {
            return minCapacity;
        }
        if (level[vertex] >= level[sink]) {
            return 0;
        }
        int currentEdge = nextEdge[vertex];
        long pushed = 0;
        while (currentEdge != -1) {
            int next = graph.end[currentEdge];
            if (level[next] == level[vertex] + 1 && graph.capacities[currentEdge] > graph.flows[currentEdge]) {
                pushed = dfs(next, Math.min(minCapacity, graph.capacities[currentEdge] - graph.flows[currentEdge]));
                if (pushed != 0) {
                    graph.pushFlow(currentEdge, pushed);
                    break;
                }
            }
            currentEdge = graph.nextOutgoing[currentEdge];
        }
        nextEdge[vertex] = currentEdge;
        return pushed;
    }

    private boolean bfs() {
        Arrays.fill(level, -1);
        level[source] = 0;
        int head = 0;
        int tail = 0;
        queue[tail++] = source;
        while (head < tail) {
            int currentVertex = queue[head++];
            int currentEdge = graph.firstOutgoing[currentVertex];
            while (currentEdge != -1) {
                int nextVertex = graph.end[currentEdge];
                if (level[nextVertex] == -1 && graph.capacities[currentEdge] > graph.flows[currentEdge]) {
                    queue[tail++] = nextVertex;
                    level[nextVertex] = level[currentVertex] + 1;
                }
                currentEdge = graph.nextOutgoing[currentEdge];
            }
        }
        return level[sink] != -1;
    }
}

class ArrayUtils {

    public static int[] resize(int[] array, int size) {
        int[] newArray = new int[size];
        System.arraycopy(array, 0, newArray, 0, array.length);
        return newArray;
    }

    public static long[] resize(long[] array, int size) {
        long[] newArray = new long[size];
        System.arraycopy(array, 0, newArray, 0, array.length);
        return newArray;
    }

    public static byte[] resize(byte[] array, int size) {
        byte[] newArray = new byte[size];
        System.arraycopy(array, 0, newArray, 0, array.length);
        return newArray;
    }
}

