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.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Map.Entry;

import static java.lang.Math.*;

public class E extends PrintWriter {

	class Edge {
		int v, rev, cap, f;

		@Override
		public String toString() {
			return "Edge [v=" + v + ", cap=" + cap + ", f=" + f + "]";
		}

		public Edge(int v, int rev, int cap) {
			this.v = v;
			this.rev = rev;
			this.cap = cap;
		}
	}

	List<Edge>[] createGraph(int nodes) {
		List<Edge>[] graph = new List[nodes];
		for (int i = 0; i < nodes; i++)
			graph[i] = new ArrayList<>();
		return graph;
	}

	void addEdge(List<Edge>[] graph, int s, int t, int cap) {
		graph[s].add(new Edge(t, graph[t].size(), cap));
		graph[t].add(new Edge(s, graph[s].size() - 1, 0));
	}

	int[] queue = new int[300];

	boolean bfs(List<Edge>[] graph, int src, int dest, int[] dist) {
		Arrays.fill(dist, -1);
		dist[src] = 0;
		int tail = 0;
		queue[tail++] = src;
		for (int head = 0; head < tail; head++) {
			int u = queue[head];
			for (Edge e : graph[u]) {
				if (dist[e.v] < 0 && e.f < e.cap) {
					dist[e.v] = dist[u] + 1;
					queue[tail++] = e.v;
				}
			}
		}
		return dist[dest] >= 0;
	}

	int dfs(List<Edge>[] graph, int[] ptr, int[] dist, int dest, int u, int f) {
		if (u == dest)
			return f;
		for (; ptr[u] < graph[u].size(); ++ptr[u]) {
			Edge e = graph[u].get(ptr[u]);
			if (dist[e.v] == dist[u] + 1 && e.f < e.cap) {
				int df = dfs(graph, ptr, dist, dest, e.v, Math.min(f, e.cap - e.f));
				if (df > 0) {
					e.f += df;
					graph[e.v].get(e.rev).f -= df;
					return df;
				}
			}
		}
		return 0;
	}

	public void maxFlow(List<Edge>[] graph, int src, int dest, int maxVal) {
		int[] dist = new int[graph.length];
		while (bfs(graph, src, dest, dist)) {
			int[] ptr = new int[graph.length];
			while (dfs(graph, ptr, dist, dest, src, maxVal) > 0) {
				continue;
			}
		}
	}

	void run() {
		int n = nextInt(), m = nextInt();
		int[] a = nextArray(n), b = nextArray(n);

		int sumA = 0, sumB = 0, sum = 100;

		int start = 0, finish = 2 * n + 1;

		List<Edge>[] graph = createGraph(finish + 1);

		for (int i = 0; i < n; i++) {
			addEdge(graph, start, i + 1, a[i]);
			addEdge(graph, i + 1, i + 1 + n, sum);
			addEdge(graph, i + 1 + n, finish, b[i]);
		}

		while (--m >= 0) {
			int u = nextInt(), v = nextInt();
			addEdge(graph, u, v + n, sum);
			addEdge(graph, v, u + n, sum);
		}

		for (int i = 0; i < n; i++) {
			sumA += a[i];
			sumB += b[i];
		}

		if (sumA != sumB) {
			println("NO");
			return;
		}

		maxFlow(graph, start, finish, sumA + sumB);

		int[][] ans = new int[n][n];

		for (int u = 1; u <= n; u++) {
			for (Edge e : graph[u]) {
				int i = u - 1, j = e.v - 1 - n, d = e.f;

				if (0 < d && 0 <= i && i < n && 0 <= j && j < n) {
					ans[i][j] += d;
					// println(u + " " + e);
				}
			}
		}

		for (int u = 0; u < n; u++) {
			for (int v = 0; v < n; v++) {
				b[u] -= ans[v][u];
			}
			if (b[u] != 0) {
				println("NO");
				return;
			}
		}
		println("YES");

		for (int u = 0; u < n; u++) {
			for (int v = 0; v < n; v++) {
				print(ans[u][v]);
				print(' ');
			}
			println();
		}

	}

	int[][] nextMatrix(int n, int m) {
		int[][] matrix = new int[n][m];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				matrix[i][j] = nextInt();
		return matrix;
	}

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

	boolean hasNext() {
		while (!tokenizer.hasMoreTokens()) {
			String line = nextLine();
			if (line == null) {
				return false;
			}
			tokenizer = new StringTokenizer(line);
		}
		return true;
	}

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

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

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

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

	String nextLine() {
		try {
			return reader.readLine();
		} catch (IOException err) {
			return null;
		}
	}

	public E(OutputStream outputStream) {
		super(outputStream);
	}

	static BufferedReader reader;
	static StringTokenizer tokenizer = new StringTokenizer("");
	static Random rnd = new Random();
	static boolean OJ;

	public static void main(String[] args) throws IOException {
		OJ = System.getProperty("ONLINE_JUDGE") != null;
		E solution = new E(System.out);
		if (OJ) {
			reader = new BufferedReader(new InputStreamReader(System.in));
			solution.run();
		} else {
			reader = new BufferedReader(new FileReader(new File(E.class.getName() + ".txt")));
			long timeout = System.currentTimeMillis();
			while (solution.hasNext()) {
				solution.run();
				solution.println();
				solution.println("----------------------------------");
			}
			solution.println("time: " + (System.currentTimeMillis() - timeout));
		}
		solution.close();
		reader.close();
	}
}