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
/*
 *
 * @author Mukesh Singh
 *
 */

import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
@SuppressWarnings("unchecked")
public class AB {	
	//solve test cases
	int residual[][];
	void solve() throws Exception {
		int n = in.nextInt() ;
		int m = in.nextInt() ;
		int[][]A = new int[2*n+2][2*n+2];
		int MAX = 1000000;
		int[]a = new int[n];
		int[]b = new int[n];
		for(int i = 0  ; i < n  ; ++i ) a[i] = in.nextInt() ;
		for(int i = 0  ; i < n  ; ++i ) b[i] = in.nextInt() ;
		for(int i = 0 ; i < m ; ++i ){
			int u = in.nextInt()-1 ;
			int v = in.nextInt()-1 ;
			A[u][n+v] = MAX ;
			A[v][n+u] = MAX ;
		}
		for(int i = 0 ;i < n; ++i ) A[i][n+i] = MAX ;
		int sum1= 0 ; 
		for(int x : a) sum1+= x ;
		int sum2= 0 ; 
		for(int x : b) sum2+= x ;
		for(int i = 0 ;i  < n ; ++i ) A[2*n][i] = a[i] ;
		for(int i = 0 ;i  < n ; ++i ) A[n+i][2*n+1] = b[i] ;
	
		int val = maxFlow( A , 2*n , 2*n+1);
		if(sum1 != sum2 || sum1 != val){
			System.out.println("NO"); return ;
		}
		System.out.println("YES");
		for(int i = 0 ; i < n ; ++i ){
			for(int j = 0 ; j < n ; ++j ){
				if(A[i][n+j] > 0 )
					System.out.print((MAX-residual[i][n+j])+" ");
				else
					System.out.print("0 ");
			}
			System.out.println();
		}
	}
	boolean bfs( int A[][] , int B[] , int src , int dest )
	{
		boolean isExists ;
		isExists = false ;
		int parent[] = new int[A[0].length];

		LinkedList<Integer> queue = new LinkedList<Integer>();
		int nodes , i , j , k , elem;

		for( i = 0 ; i < parent.length ; i++)
			parent[i] = -1 ;

		for( i = 0 ; i < B.length ; i++)
			B[i] = -1 ;

		nodes = A[0].length ;
		int visited[] = new int[nodes];	
		queue.addLast(src);
		elem = src ;
		j = 0 ;
		visited[elem] = 1;

	outer :	while (queue.size() > 0 )
        {
            elem = queue.removeFirst();			
			i = 0 ;	
		    while (i <  nodes)
		    {
     	        if (A[elem][i] != 0  && visited[i] == 0)
		        {
                    queue.addLast(i);
                    visited[i] = 1;
					parent[i] = elem ;
					if ( i == dest)
					{ isExists= true;	break outer ;}
                }
                i++;
	    	}
            	
        }
	
		if(isExists)
		{
			j = 0 ;
			visited[j] = dest ;
			j++ ;
			while( true )
			{
				i = parent[i] ;
				visited[j] = i ;
				j++;
				if( i == src )
					break ;				
			}
		
		for( j = j -1 , i = 0; j>=0 ; j--,i++ )
			B[i] = visited[j] ;
		}
		return isExists;
	}

	int maxFlow( int A[][] , int source , int sink)
	{
		int n = A[0].length ;
		residual = new int[n][n] ;
		int B[] = new int[n] ;
		int  i , j , k , max ;
		for( i = 0 ; i < n ; i ++ )
			for( j = 0 ; j < n ; j++)
				residual[i][j] = A[i][j] ;
		max = 0 ;
		for( i = 0 ; i < n ; i ++)
			B[i] = -1 ;
		while(bfs(residual,B,source,sink))
		{
			i = 0 ;
			k = residual[B[i]][B[i+1]] ;
			i++ ;
			while((i+1 < B.length) && B[i+1] != -1)
			{
				if( k > residual[B[i]][B[i+1]])
					k = residual[B[i]][B[i+1]] ;
				i++;
			}
			i = 0 ;
			while((i+1 < B.length) && B[i+1] != -1)
			{
					residual[B[i]][B[i+1]] -= k  ;
					residual[B[i+1]][B[i]] += k  ;
				i++;
			}
			for( i = 0 ; i < n ; i ++)
				B[i] = -1 ;
			max = max + k ;
		}
		return max ;
	}
	
	// second methods starts here c : cost and f : for residual(initialize to 0)
	int flow(int n , int[][]c , int[][]f , int s , int t)
	{
		boolean[] mark = new boolean[n];
		int res = 0 ;
		while(dfs(s,t,c,f,mark))
		{
			res++ ;
			Arrays.fill(mark , false);
		}
		return res ;
	}
	boolean dfs(int at ,int t , int[][] c , int[][] f , boolean[] mark)
	{
		if(at==t)
			return true ;
		if(mark[at])
			return false ;
		mark[at] = true ;
		for(int i = 0 ; i < c.length ; ++i)
		{
			if(f[at][i] < c[at][i] && dfs(i , t ,  c, f , mark))
			{
				++f[at][i];
				--f[i][at];
				return true ;
			}
		}
		return false ;
	}

	//@ main function
	public static void main(String[] args) throws Exception {
		new AB();
	}
	
	InputReader in;
	PrintStream out ;
	DecimalFormat df ;
	AB() {
		try {
			File defaultInput = new File("file.in");
			if (defaultInput.exists()) 
				in = new InputReader("file.in");
			else 
				in = new InputReader();
			defaultInput = new File("file.out");
			if (defaultInput.exists()) 
				out = new PrintStream(new FileOutputStream("file.out"));
			else
				out = new PrintStream(System.out);
			df = new DecimalFormat("######0.00");
			solve();
			out.close();
		} 
		catch (Exception e) {
			e.printStackTrace();
			System.exit(261);
		}
	}
	
	class InputReader {
		BufferedReader reader;
		StringTokenizer tokenizer;
		
		InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
		}
		
		InputReader(String fileName) throws FileNotFoundException {
			reader = new BufferedReader(new FileReader(new File(fileName)));
		}
		
		String readLine() throws IOException {
			return reader.readLine();
		}
		
		String nextToken() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens())
				tokenizer = new StringTokenizer(readLine());
			return tokenizer.nextToken();
		}
		
		boolean hasMoreTokens() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				String s = readLine();
				if (s == null)
					return false;
				tokenizer = new StringTokenizer(s);
			}
			return true;
		}
		
		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextToken());
		}
		
		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(nextToken());
		}
		
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(nextToken());
		}
	}
}
