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.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.AbstractCollection;
import java.io.Writer;
import java.util.LinkedList;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author walker
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.readInt();
        int m = in.readInt();
        int[][] cap = new int[2 * n + 2][2 * n + 2];
        int[][] f = new int[2 * n + 2][2 * n + 2];
        int[] supp = IOUtils.readIntArray(in, n);
        int[] req = IOUtils.readIntArray(in, n);
        int source = 2 * n;
        int sink = 2 * n + 1;
        int suma = 0, sumb = 0;
        for(int i = 0; i < n; i++){
            cap[i + n][sink] = req[i];
            cap[source][i] = supp[i];
            cap[i][i + n] = supp[i];
            suma += supp[i];
            sumb += req[i];
        }
        for(int i = 0; i < m; i++){
            int u = in.readInt() - 1;
            int v = in.readInt() - 1;
            cap[u][n + v] = supp[u];
            cap[v][n + u] = supp[v];
        }
        if(suma != sumb || maxFlow(cap, f, source, sink) != suma){
            out.print("NO");
        }
        else{
            out.println("YES");
            for(int i = 0; i < n; i++){
                for(int j = n; j < 2 * n; j++){
                    if(cap[i][j] > 0){
                        out.print(f[i][j]);
                    }
                    else{
                        out.print(0);
                    }
                    out.print(" ");
                }
                out.println();
            }
        }

    }

    public int maxFlow(int[][] cap, int[][] f, int source, int sink){
        boolean done = false;
        int flow = 0;
        while(!done){
            LinkedList<Integer> Q = new LinkedList<>();
            boolean[] visited = new boolean[cap.length];
            int[] prev = new int[cap.length];
            Q.add(source);
            prev[source] = -1;
            while(!Q.isEmpty() && !visited[sink]){
                int v = Q.removeFirst();
                visited[v] = true;
                for(int i = 0; i < cap.length; i++){
                    if(!visited[i] && cap[v][i] > 0 && f[v][i] < cap[v][i]){
                        prev[i] = v;
                        Q.add(i);
                    }
                    else if(!visited[i] && cap[v][i] == 0 && f[i][v] > 0){
                        prev[i] = v;
                        Q.add(i);
                    }
                }
            }
            if(!visited[sink]){
                done = true;
            }
            else{
                int curr = sink;
                int last = prev[curr];
                int u = Integer.MAX_VALUE;
                while(last != -1){
                    if(cap[last][curr] > 0 && f[last][curr] < cap[last][curr]){
                        u = Math.min(u, cap[last][curr] - f[last][curr]);
                    }
                    else{
                        u = Math.min(u, f[curr][last]);
                    }
                    curr = last;
                    last = prev[curr];
                }
                flow += u;
                curr = sink;
                last = prev[curr];
                while(last != -1){
                    if(cap[last][curr] > 0 && f[last][curr] < cap[last][curr]){
                        f[last][curr] += u;
                    }
                    else{
                        f[curr][last] -= u;
                    }
                    curr = last;
                    last = prev[curr];
                }
            }
        }
        return flow;
    }
    
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

    public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

    public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

class IOUtils {

	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.readInt();
		return array;
	}

}

