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.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Queue;

public class E {
	class MaximumFlowNeo {
		int n;
		int[][] pipe;
		int source, sink;
		int flow;
		int[][] matrix;

		MaximumFlowNeo(int n, int[][] pipe, int source, int sink) {
			this.n = n;
			this.pipe = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					this.pipe[i][j] = pipe[i][j];
				}
			}
			this.source = source;
			this.sink = sink;
			doit();
		}

		void doit() {
			flow = 0;
			matrix = new int[n][n];

			int[] min = new int[n];
			int[] pre = new int[n];
			Arrays.fill(min, Integer.MAX_VALUE);
			while (bfs(min, pre)) {
				flow += min[sink];
				for (int i = sink; i != pre[i]; i = pre[i]) {
					pipe[pre[i]][i] -= min[sink];
					pipe[i][pre[i]] += min[sink];
					matrix[pre[i]][i] += min[sink];
					matrix[i][pre[i]] -= min[sink];
				}
				Arrays.fill(min, Integer.MAX_VALUE);
			}
		}

		boolean bfs(int[] min, int[] pre) {
			Queue<Integer> queue = new LinkedList<Integer>();
			queue.offer(source);
			pre[source] = source;
			int[] vis = new int[n];
			while (!queue.isEmpty()) {
				int idx = queue.poll();
				if (vis[idx] == 1) {
					continue;
				}
				vis[idx] = 1;
				for (int i = 0; i < n; i++) {
					if (0 < pipe[idx][i] && vis[i] == 0) {
						pre[i] = idx;
						min[i] = Math.min(min[pre[i]], pipe[idx][i]);
						if (i == sink) {
							return true;
						}
						queue.offer(i);
					}
				}
			}

			return false;
		}

		int getOptimal() {
			return flow;
		}

		int[][] getMatrix() {
			return matrix;
		}
	}

	void run() {
		MyScanner sc = new MyScanner();

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = sc.nextIntArray(n);
		int[] b = sc.nextIntArray(n);
		int[][] nei = new int[n][n];
		for (int i = 0; i < m; i++) {
			int s = sc.nextInt() - 1;
			int t = sc.nextInt() - 1;
			nei[s][t] = nei[t][s] = 1;
		}
		int sumA = 0, sumB = 0;
		for (int i = 0; i < n; i++) {
			sumA += a[i];
			sumB += b[i];
		}

		int[][] flow = new int[n + n + 2][n + n + 2];
		for (int i = 0; i < n; i++) {
			flow[0][i + 1] = a[i];
			flow[n + i + 1][n + n + 1] = b[i];
		}
		for (int i = 0; i < n; i++) {
			flow[i + 1][i + n + 1] = 20000;
			for (int j = i + 1; j < n; j++) {
				if (nei[i][j] == 0) {
					continue;
				}
				flow[i + 1][j + n + 1] = 20000;
				flow[j + 1][i + n + 1] = 20000;
			}
		}

		MaximumFlowNeo mf = new MaximumFlowNeo(n + n + 2, flow, 0, n + n + 1);
		if (sumA != sumB || mf.getOptimal() != sumB) {
			System.out.println("NO");
			return;
		} else {
			System.out.println("YES");
			int[][] res = mf.getMatrix();
			for (int i = 1; i < n + 1; i++) {
				String tab = "";
				for (int j = n + 1; j < n + n + 1; j++) {
					System.out.print(tab + res[i][j]);
					tab = " ";
				}
				System.out.println();
			}
		}
	}

	public static void main(String[] args) {
		new E().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

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

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

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

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

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

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

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

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