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.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;

public class E {

	static int n,m;
	static int[] source;
	static int[] dest;
	static List<List<Integer>> g = new ArrayList<List<Integer>>();
	static int[][] sol;
	static int[][] edges;

	public static void main(String[] args) throws IOException {
		int[] l = readIntArray();
		n = l[0];
		sol = new int[n][n];
		for (int i = 0; i < n; i++) {
			g.add(new ArrayList<Integer>());
		}
		m = l[1];
		source = readIntArray();
		dest = readIntArray();
		edges = new int[m][];
		for (int i = 0; i < m; i++) {
			l = readIntArray();
			l[0]--;l[1]--;
			g.get(l[0]).add(l[1]);
			g.get(l[1]).add(l[0]);
			edges[i] = l;
		}
		
		long sourceSum = 0;
		for (int i = 0; i < source.length; i++) {
			sourceSum += source[i];
		}
		long destSum = 0;
		for (int i = 0; i < dest.length; i++) {
			destSum += dest[i];
		}		
		if (sourceSum != destSum) {
			System.out.println("NO");
			return;
		}
		
		int n = 2*source.length + 2;
		int[][] r = new int[n][n];
		int s = 0;
		int t = n - 1;
		int expFlow = 0;
		for (int i = 0; i < source.length; i++) {
			if (source[i] >= dest[i]) {
				r[s][2*i + 1] = source[i] - dest[i];
				r[2*i + 1][2*i + 2] = source[i];
				expFlow += Math.abs(source[i] - dest[i]);
			} else {
				r[2*i+2][t] = dest[i] - source[i];
				r[2*i + 1][2*i + 2] = dest[i];
			}
		}
		
		for (int i = 0; i < m; i++) {
			r[2 * edges[i][0] + 2][2 * edges[i][1] + 1] = 1000;
			r[2 * edges[i][1] + 2][2 * edges[i][0] + 1] = 1000;
		}
		
		EdmondsKarp ek = new EdmondsKarp(s, t, r);
		ek.solve();
//		System.out.println(ek.getMaxFlowValue());
//		ek.print();
		if (ek.getMaxFlowValue() == expFlow) {
			for (int i = 0; i < source.length; i++) {
				if (dest[i] > source[i])
					sol[i][i] = source[i] - (ek.r[2*i + 2][2*i + 1] - dest[i] + source[i]);
				else 
					sol[i][i] = source[i] - ek.r[2*i + 2][2*i + 1];
			}
			for (int i = 0; i < m; i++) {
				sol[edges[i][0]][edges[i][1]] = ek.r[2*edges[i][1] + 1][2*edges[i][0] + 2];
				sol[edges[i][1]][edges[i][0]] = ek.r[2*edges[i][0] + 1][2*edges[i][1] + 2];
			}
			
			System.out.println("YES");
			for (int i = 0; i < sol.length; i++) {
				print(sol[i]);
			}
		} else {
			System.out.println("NO");
		}
	}
	
	static class EdmondsKarp {
		public int[][] r;
		public int s, t, n;
		
		public EdmondsKarp(int s, int t, int[][] r) {
			this.s = s;
			this.t = t;
			this.n = r.length;
			this.r = new int[r.length][r[0].length];
			for (int i = 0; i < r.length; i++) {
				for (int j = 0; j < r[0].length; j++) {
					this.r[i][j] = r[i][j];
				}
			}
		}
		
		public void print() {
			for (int i = 0; i < r.length; i++) {
				System.out.println(Arrays.toString(r[i]));
			}
		}
		
		public int getMaxFlowValue() {
			int flow = 0;
			for (int i = 0; i < n; i++) {
				flow += r[i][s];
			}
			
			return flow;
		}
		
		public void solve() {
			while(true) {
				List<Integer> augmentingPath = this.findAugmentingPath();
				if (augmentingPath == null) {
					break;
				}
				
				push(augmentingPath);
			}
		}
		
		private List<Integer> findAugmentingPath() {
			
			LinkedList<Integer> q = new LinkedList<Integer>();
			q.add(this.s);
			boolean[] v = new boolean[this.n];
			v[s] = true;
			int[] pred = new int[this.n];
			Arrays.fill(pred, -1);
			boolean found = false;
			while(!q.isEmpty()) {
				int current = q.removeFirst();
				if (current == t) {
					found = true;
					break;
				}
				for (int i = 0; i < r[0].length; i++) {
					if (r[current][i] > 0 && !v[i]) {
						q.addLast(i);
						v[i] = true;
						pred[i] = current;
					}
				}
			}
			
			if (found) {
				ArrayList<Integer> ans = new ArrayList<Integer>();
				
				int current = this.t;
				while(true) {
					ans.add(current);
					if (current == this.s) {
						break;
					}
					current = pred[current];
				}
				
				this.reverse(ans);
				
				return ans;
			}
			
			return null;
		}
		
		private void reverse(ArrayList<Integer> ans) {
			for (int i = 0; i < ans.size() / 2; i++) {
				int x = ans.get(i);
				ans.set(i, ans.get(ans.size() - i - 1));
				ans.set(ans.size() - i - 1, x);
			}
		}

		private void push(List<Integer> ap) {
			int flowToPush = Integer.MAX_VALUE;
			for (int i = 0; i < ap.size() - 1; i++) {
				int v1 = ap.get(i);
				int v2 = ap.get(i+1);
				flowToPush = Math.min(flowToPush, r[v1][v2]);
			}
			for (int i = 0; i < ap.size() - 1; i++) {
				int v1 = ap.get(i);
				int v2 = ap.get(i+1);
				r[v1][v2] -= flowToPush;
				r[v2][v1] += flowToPush;
			}
		}
	}
	
	static InputStreamReader isr = new InputStreamReader(System.in);
	static BufferedReader br = new BufferedReader(isr);

	static int[] readIntArray() throws IOException {
		String[] v = br.readLine().split(" ");
		int[] ans = new int[v.length];

		for (int i = 0; i < ans.length; i++) {
			ans[i] = Integer.valueOf(v[i]);
		}

		return ans;
	}

	static long[] readLongArray() throws IOException {
		String[] v = br.readLine().split(" ");
		long[] ans = new long[v.length];

		for (int i = 0; i < ans.length; i++) {
			ans[i] = Long.valueOf(v[i]);
		}

		return ans;
	}

	static void print(int[] sol2) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < sol2.length; i++) {
			if (sb.length() > 0) {
				sb.append(' ');
			}

			sb.append(sol2[i]);
		}

		System.out.println(sb);
	}
	
	static <T> void print(List<T> v) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < v.size(); i++) {
			if (sb.length() > 0) {
				sb.append(' ');
			}

			sb.append(v.get(i));
		}

		System.out.println(sb);
	}
}
