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.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;

public class E546 {
	static class Solver {

		int N, M, sum = 0, asum = 0, ans[][]; Dinic D;
		
		void solve(int testNumber, FastScanner s, PrintWriter out) {
			N = s.nextInt(); M = s.nextInt(); D = new Dinic(2 * N);
			for (int i = 0, w; i < N; i++) {
				D.add(D.s, i, w = s.nextInt(), 0);
				D.add(i, N + i, 987654321, 0);
				asum += w;
			}
			for (int i = 0, w; i < N; i++) {
				D.add(N + i, D.t, w = s.nextInt(), 0); sum += w; }
			for(int i = 0, u, v; i < M; i++) {
				u = s.nextInt() - 1; v = s.nextInt() - 1;
				D.add(u, N + v, 987654321, 0);
				D.add(v, N + u, 987654321, 0);
			}
			if(sum != asum || D.flow() != sum) { out.println("NO"); return; }
			out.println("YES");
			ans = new int[N][N];
			for(int i = 0; i < N; i++) {
				for(Dinic.Edge e : D.adj[i])
					if(e.v2 != D.s && e.v2 != D.t)
						ans[i][e.v2 - N] = e.flow;
				for(int j : ans[i]) out.print(j + " ");
				out.println();
			}
		}
		
		static class Dinic {
			static class Edge {  int v1, v2, cap, flow; Edge rev;
				Edge(int V1, int V2, int Cap, int Flow) { v1 = V1; v2 = V2; cap = Cap; flow = Flow; }
			}

			ArrayDeque<Integer> q;  ArrayList<Edge>[] adj;
			int n, s, t, mS, mT, oo = (int)1E9;
			boolean[] blocked;  int[] dist;
			@SuppressWarnings("unchecked")
			public Dinic (int N) {
				n = N; s = n++; t = n++; mS = n++; mT = n++; blocked = new boolean[n];
				dist = new int[n];  q = new ArrayDeque<Integer>();
				adj = new ArrayList[n];  for(int i = 0; i < n; ++i)  adj[i] = new ArrayList<Edge>();
			}
			// Specifying flow can represent minimum flow for circulation.
			Edge add(int v1, int v2, int cap, int flow) {
				Edge e = new Edge(v1, v2, cap, flow);  Edge rev = new Edge(v2, v1, 0, 0);
				adj[v1].add(rev.rev = e);  adj[v2].add(e.rev = rev);
				return e;
			}
			boolean bfs() {
				q.clear();  Arrays.fill(dist, -1);  dist[t] = 0;  q.add(t);

				while(!q.isEmpty()) {
					int node = q.poll();
					if(node == s)   return true;
					for(Edge e : adj[node]) {
						if(e.rev.cap > e.rev.flow && dist[e.v2] == -1) {
							dist[e.v2] = dist[node] + 1;  q.add(e.v2);
						}
					}
				}
				return dist[s] != -1;
			}

			int dfs(int pos, int min) {
				if(pos == t)  return min;
				int flow = 0;
				for(Edge e : adj[pos]) {
					int cur = 0;
					if(!blocked[e.v2] && dist[e.v2] == dist[pos]-1 && e.cap - e.flow > 0) {
						cur = dfs(e.v2, Math.min(min-flow, e.cap - e.flow));
						e.flow += cur;  e.rev.flow = -e.flow;  flow += cur;
					}
					if(flow == min)  return flow;
				}
				blocked[pos] = flow != min;
				return flow;
			}
			int flow() {
				clear();  int ret = 0;
				while(bfs()) {  Arrays.fill(blocked, false);  ret += dfs(s, oo);  }
				return ret;
			}
			void clear() {  for(ArrayList<Edge> edges : adj)  for(Edge e : edges)  e.flow = 0;  }
		}

	}

	final static boolean cases = false;

	public static void main(String[] args) {

		FastScanner s = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Solver solver = new Solver();
		for (int t = 1, T = cases ? s.nextInt() : 1; t <= T; t++)
			solver.solve(t, s, out);

		out.close();

	}

	static int min(int a, int b) {
		return a < b ? a : b;
	}

	static int max(int a, int b) {
		return a > b ? a : b;
	}

	static long min(long a, long b) {
		return a < b ? a : b;
	}

	static long max(long a, long b) {
		return a > b ? a : b;
	}

	static int swap(int a, int b) {
		return a;
	}

	static Object swap(Object a, Object b) {
		return a;
	}

	static String ts(Object... o) {
		return Arrays.deepToString(o);
	}

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

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

		public FastScanner(File f) throws FileNotFoundException {
			this(new FileInputStream(f));
		}

		public FastScanner(String s) {
			this.stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
		}

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

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}

		// Jacob Garbage

		public int[] nextIntArray(int N) {
			int[] ret = new int[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextInt();
			return ret;
		}

		public int[][] next2DIntArray(int N, int M) {
			int[][] ret = new int[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextIntArray(M);
			return ret;
		}

		public long[] nextLongArray(int N) {
			long[] ret = new long[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextLong();
			return ret;
		}

		public long[][] next2DLongArray(int N, int M) {
			long[][] ret = new long[N][];
			for (int i = 0; i < N; i++)
				ret[i] = nextLongArray(M);
			return ret;
		}

		public double[] nextDoubleArray(int N) {
			double[] ret = new double[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDouble();
			return ret;
		}

		public double[][] next2DDoubleArray(int N, int M) {
			double[][] ret = new double[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDoubleArray(M);
			return ret;
		}

	}
}
