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.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Soldier_Traveling {
	
	public static class Max__Flow{
        public int size = 0;
 
        public boolean bfs(int[][] graph, int end, int[] parent) {
            Queue<Integer> Q = new LinkedList<Integer>();
            Q.add(0);
            //initialize visited array
            boolean[] visited = new boolean[end+1];
            parent[0] = -1;
 
            while(!Q.isEmpty()) {
                int temp = Q.poll();
                visited[temp] = true;
                if(visited[end] == true){
                    return true;
                }
                for(int a = 0; a <= end; a++){
                    if (visited[a] == false && graph[temp][a] > 0) {
                        parent[a] = temp;
                        Q.add(a);
                    }
                }
            }
            return false;
        }
    
        public int mod_Ford_Fulk(int[][] chengshi){
            int[] parent = new int[2*this.size+2];
 
            int Max__Flow = 0;
            while (bfs(chengshi, 2*size+1, parent)) {
                int path_flow = Integer.MAX_VALUE;
                for (int a = parent.length-1; a != 0; a=parent[a]) {
                    path_flow = Math.min(path_flow, chengshi[parent[a]][a]);
                }
                Max__Flow += path_flow;
                //mark
                for (int a = parent.length-1; a != 0; a=parent[a]) {
                    chengshi[parent[a]][a] -= path_flow;
                    chengshi[a][parent[a]] += path_flow;
                }
            }
            return Max__Flow;
        }
    }
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[][] chengshi = new int[2*N+2][2*N+2];
		
		int sink = 2*N+1;
		int roads = scan.nextInt();
	    int total = 0; 
        int totalcheck = 0;
 
        for (int a = 1; a <= N; a++) {
            chengshi[0][a] = scan.nextInt();
            total += chengshi[0][a];
		}
		for (int a = 1; a <= N; a++) {
            chengshi[a+N][sink] = scan.nextInt();
            totalcheck += chengshi[a+N][sink];
            
		}
	
    	for(int a = 1;a  <= N;a++) {
            chengshi[a][a + N] = Integer.MAX_VALUE;
        }
        
        if(total != totalcheck){
            System.out.println("NO");
            System.exit(0);
        }
 
		for (int a = 0; a < roads; a++) {
			int x = scan.nextInt();
			int y = scan.nextInt();
			chengshi[x][y+N] = Integer.MAX_VALUE;
			chengshi[y][x+N] = Integer.MAX_VALUE;
		}
        
        Max__Flow calc = new Max__Flow();
        calc.size = N;
        int Max__Flow = calc.mod_Ford_Fulk(chengshi);
	
    
    	if(Max__Flow == total){
		   System.out.println("YES");
           for(int a = 1; a < N + 1; a++){
               for(int b = N + 1; b < 2 * N + 1; b++) {
                   System.out.print(chengshi[b][a] + " ");
               }
               System.out.println();
           }
		} 
        else{
			System.out.println("NO");
		}
         
	}

}