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.*;
import java.io.*;


public class Main implements Runnable {
		
	public void solve() throws IOException {
               int n = nextInt();
               int m = nextInt();
               int[] a = new int[n];
               for(int i = 0; i < n; i++){
                       a[i] = nextInt();
               }
               int[] b = new int[n];
               for(int i = 0; i < n; i++){
                       b[i] = nextInt();
               }
               
               int s = 0;
               for(int i = 0; i < n; i++){
                       s += a[i];
               }
               for(int j = 0; j < n; j++){
                       s -= b[j];
               }
               if(s != 0){
                       out.println("NO");
                       return;
               }
               
               FlowEdge[][] res = new FlowEdge[n][n];
               
               int INF = 2000;
               DinicFlow fg = new DinicFlow(n + n + 2);
               int src = n + n;
               int tgt = n + n + 1;
               for(int i = 0; i < n; i++) fg.addEdge(src, i, a[i]);
               for(int i = 0; i < n; i++) fg.addEdge(i+n, tgt, b[i]);
               for(int i = 0; i < n; i++) res[i][i] = fg.addEdge(i, i+n, INF);
               for(int i = 0; i < m; i++){
                       int u = nextInt() - 1;
                       int v = nextInt() - 1;
                       res[u][v] = fg.addEdge(u, v + n, INF);
                       res[v][u] = fg.addEdge(v, u + n, INF);
               }
               
               s = 0;
               for(int i = 0; i < n; i++) s += a[i];
               
               
               if(fg.getMaxFlow(src, tgt) != s){
                       out.println("NO");
                       return;
               }
               
               out.println("YES");
               for(int i = 0; i < n; i++){
                       for(int j = 0; j < n; j++){
                               if(j > 0) out.print(" ");
                               if(res[i][j] == null) out.print(0);
                               else out.print(res[i][j].flow);
                       }
                       out.println();
               }
	}
        
        static class FlowEdge{
                int from, to, cap, flow;
                FlowEdge rev;
                public FlowEdge(int from, int to, int flow , int cap){
                        this.from = from;
                        this.to = to;
                        this.flow = flow;
                        this.cap = cap;
                }
        }
        
        class DinicFlow{
                ArrayList<FlowEdge>[] graph;
                int[] ptr;
                int[] dist;
                Queue<Integer> q;
                int n;
                DinicFlow(int n){
                        this.n = n;
                        graph = new ArrayList[n];
                        for(int i = 0; i < n; i++) graph[i] = new ArrayList<>();
                        ptr = new int[n];
                        dist = new int[n];
                        q = new ArrayDeque<Integer>();
                }
                
                public FlowEdge addEdge(int from, int to, int cap){
                    FlowEdge e1 = new FlowEdge(from, to, 0, cap);
                    FlowEdge e2 = new FlowEdge(to, from, 0, 0);
                    e1.rev = e2;
                    e2.rev = e1;
                    graph[from].add(e1);
                    graph[to].add(e2);
                    return e1;
                }
                
                public int getMaxFlow(int src, int tgt){
                        int flow = 0;
                        while(bfs(src, tgt)){
                                Arrays.fill(ptr, 0);
                                int curFlow = 0;
                                do{
                                        curFlow = dfs(src, tgt, Integer.MAX_VALUE / 5);
                                        flow += curFlow;
                                }while(curFlow > 0);
                        }
                        
                        return flow;
                }
                
                public boolean bfs(int src, int tgt){
                        Arrays.fill(dist, Integer.MAX_VALUE / 5);
                        q.clear();
                        dist[src] = 0;
                        q.add(src);
                        while(!q.isEmpty()){
                                int x = q.poll();
                                for(FlowEdge e : graph[x]){
                                        if(e.flow < e.cap && dist[e.to] == Integer.MAX_VALUE / 5){
                                                dist[e.to] = dist[x] + 1;
                                                q.add(e.to);
                                        }
                                }
                        }
                        
                        return dist[tgt] < Integer.MAX_VALUE / 5;
                }
                
                public int dfs(int x, int tgt,  int flow){
                        if(x == tgt)
                                return flow;
                        for(int i = ptr[x]; i < graph[x].size(); i = ptr[x]){
                                FlowEdge e  = graph[x].get(i);
                                ptr[x]++;
                                if(dist[e.to] == dist[x] + 1 && e.flow < e.cap){
                                        int add = dfs(e.to, tgt, Math.min(flow, e.cap - e.flow));
                                        if(add == 0)
                                                continue;
                                        e.flow += add;
                                        e.rev.flow -= add;
                                        return add;
                                }
                        }
                        
                        return 0;
                }
        }
        
        
        

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

        public void debug(Object... arr){
            System.out.println(Arrays.deepToString(arr));
        }

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }
        
        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }
        
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
			tok = null;
			solve();
			in.close();
                        out.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

	public String nextToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
        PrintWriter out;
	BufferedReader in;
	StringTokenizer tok;
}