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.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Collection;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.NoSuchElementException;
import java.util.Queue;
import java.math.BigInteger;
import java.io.InputStream;

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

class TaskE {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
	    int n = in.readInt();
	    int m = in.readInt();
	    MaximumFlowGraph G = new MaximumFlowGraph(2* n + 2, 2 * n, 2 * n + 1);
	    int[] supp = IOUtils.readIntArray(in, n);
	    int[] req = IOUtils.readIntArray(in, n);
	    int source = 2 * n;
	    int sink = 2 * n + 1;
	    int suma = 0, sumb = 0;
	    for(int i = 0; i < n; i++){
		    G.addEdge(i + n, sink, req[i]);
		    G.addEdge(source, i, supp[i]);
		    G.addEdge(i, n + i, supp[i]);
		    sumb += req[i];
		    suma += supp[i];
	    }
	    for(int i = 0; i < m; i++){
		    int u = in.readInt() - 1;
		    int v = in.readInt() - 1;
		    G.addEdge(u, n + v, supp[u]);
		    G.addEdge(v, n + u, supp[v]);
	    }
	    long flow = G.getFlow();
	    if(flow != sumb || suma != sumb){
		    out.print("NO");
	    }
	    else{
		    out.printLine("YES");
		    long[][] ans = new long[n][n];
		    for(MaximumFlowGraph.Edge e : G.e) {
			    if (e.from >= 0 && e.from < n && e.to >= n && e.to < 2 * n) ans[e.from][e.to - n] = e.flow;
		    }
		    for(int i = 0; i < n; i++) {
			    for(int j = 0; j < n; j++) {
				    out.print(ans[i][j] + " ");
			    }
			    out.printLine();
		    }
	    }
    }

	class MaximumFlowGraph {
		final long INF = (long) 1e13;

		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;
			}
		}

		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);
					}
				}
			}
			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() {
			long flow = 0;
			while (bfs()) {
				Arrays.fill(first, 0);
				while (dfs(source, -1))
					flow += pushFlow();
			}
			return flow;
		}
	}
}

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

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

	public 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 boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}
	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}
	public void printLine() {
		writer.println();
	}

    public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}
	public void close() {
		writer.close();
	}
}

class IOUtils {
	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readInt();
		return array;
	}
}