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.util.*;

public class SoldierAndTraveling
{

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		Dinic g = new Dinic(n*2);
		int s1 = 0;
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
			g.add(g.s, i, a[i], 0);
			s1 += a[i];
		}
		int s2 = 0;
		for(int i = 0; i < n; i++) {
			b[i] = scan.nextInt();
			g.add(i+n, g.t, b[i], 0);
			s2 += b[i];
		}
		for(int i = 0; i < n; i++) {
			g.add(i, i+n, g.oo, 0);
		}
		if(s1 != s2) {
			System.out.println("NO");
			return;
		}
		for(int i = 0; i < m; i++) {
			int u = scan.nextInt()-1;
			int v = scan.nextInt()-1;
			g.add(u, n+v, g.oo, 0);
			g.add(v, n+u, g.oo, 0);
		}
		int f = g.flow();
		if(f == s2) {
			System.out.println("YES");
			int[][] ans = new int[n][n];
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < g.adj[i].size(); j++) {
					int u = g.adj[i].get(j).v1;
					int v = g.adj[i].get(j).v2;
//					System.out.println(u+" "+v);
					if(v >= n && v < 2*n)
						ans[u][v-n] += g.adj[i].get(j).flow;
				}
			}
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					System.out.print(ans[i][j]+" ");
				}
				System.out.println();
			}
		}
		else {
			System.out.println("NO");
		}
		
	}
	
	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, oo = (int)1E9;
		boolean[] blocked;  int[] dist;
		public Dinic (int N) {
			n = N; s = n++; t = 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.
		void 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);
		}

		//#
		// Only needed if you need remove function
		void remove(int v1, int v2) {
			Edge e;
			for(int i = 0; i < adj[v1].size(); i++) {
				e = adj[v1].get(i);
				if(e.v2 == v2 && e.cap != 0)  adj[v1].remove(i--);
			}

			for(int i = 0; i < adj[v2].size(); i++) {
				e = adj[v2].get(i);
				if(e.v2 == v1 && e.cap == 0)  adj[v2].remove(i--);
			}
		}
		//$
		
		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;  }
	}
}
