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.*;
import static java.lang.Math.*;
import java.util.*;
import java.util.function.*;
import java.lang.*;

public class Main {
    final static boolean debug = false;
    final static String fileName = "";
    final static boolean useFiles = false;

    public static void main(String[] args) throws FileNotFoundException {
        long start;
        if (debug)
            start = System.nanoTime();
        InputStream inputStream;
        OutputStream outputStream;
        if (useFiles) {
            inputStream = new FileInputStream(fileName + ".in");
            outputStream = new FileOutputStream(fileName + ".out");
        } else {
            inputStream = System.in;
            outputStream = System.out;
        }
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task(in, out);
        solver.solve();
        if(debug)
            out.println((System.nanoTime() - start) / 1e+9);
        out.close();
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public byte nextByte() {
        return Byte.parseByte(next());
    }

    byte[][] nextBitMatrix(int n, int m) {
        byte[][] a = new byte[n][m];
        for (int i = 0; i < n; i++) {
            String s = next();
            for (int j = 0; j < m; j++) {
                a[i][j] = (byte) (s.charAt(j) - '0');
            }
        }
        return a;
    }

    char[][] nextCharMatrix(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            String s = next();
            for (int j = 0; j < m; j++) {
                a[i][j] = s.charAt(j);
            }
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }
}

class Task {
    public void solve() {
        int n = in.nextInt();
        int m = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        int[] b = new int[n];
        for (int i = 0; i < n; i++)
            b[i] = in.nextInt();
        int[] volume = new int[n];
        for (int i = 0; i < n; i++) {
            volume[i] = a[i] - b[i];
        }
        final int INFINITY = (int) 1e9;
        int[][] c = new int[2 * n + 2][2 * n + 2];
        int source = 2 * n;
        int target = 2 * n + 1;
        for (int i = 0; i < m; i++) {
            int p = in.nextInt() - 1;
            int q = in.nextInt() - 1;
            c[q][p + n] = c[p][q + n] = INFINITY;
//            if (volume[p] == 0 || volume[q] == 0 || volume[p] > 0 && volume[q] > 0 || volume[p] < 0 && volume[q] < 0)
//                continue;
//            if (volume[q] > 0) {
//                int t = q;
//                q = p;
//                p = t;
//            }
//            assert volume[q] < 0 && volume[p] > 0;
//            c[p][q] = INFINITY;
        }
        for (int i = 0; i < n; i++){
            c[source][i] = a[i];
            c[i + n][target] = b[i];
            c[i][i + n] = INFINITY;
        }
//        for (int i = 0; i < n; i++) {
//            if (volume[i] > 0){
//                c[source][i] = volume[i];
//            }
//            if (volume[i] < 0){
//                c[i][target] = -volume[i];
//            }
//        }
//        for (int i = 0; i < n + 2; i++){
//            for (int j = 0; j < n + 2; j++){
//                out.print(c[i][j] + " ");
//            }
//            out.println();
//        }
        Dinic dinic = new Dinic(c, source, target);
        dinic.maxFlow();
        int[][] flow = dinic.flow;
        for (int i = 0; i < n; i++) {
            if (flow[source][i] != c[source][i] || flow[i + n][target] != c[i + n][target]){
                out.println("NO");
                return;
            }
//            if (volume[i] == 0)
//                continue;
//            if (volume[i] > 0 && c[source][i] != flow[source][i] || volume[i] < 0 && c[i][target] != flow[i][target]){
//                out.println("NO");
//                return;
//            }
        }
        out.println("YES");
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                out.print(flow[i][j + n] + " ");
            }
            out.println();
        }
    }

    private InputReader in;
    private PrintWriter out;

    Task(InputReader in, PrintWriter out) {
        this.in = in;
        this.out = out;
    }
}

class Dinic {
    final int inf = (int) (1e+9);
    int[][] capacity, flow;
    int n, source, target;
    int[] d, last;

    public Dinic(int[][] c, int s, int t) {
        capacity = c;
        n = c.length;
        d = new int[n];
        last = new int[n];
        flow = new int[n][n];
        source = s;
        target = t;
    }

    private boolean bfs() {
        Arrays.fill(d, -1);
        Queue<Integer> queue = new ArrayDeque<>();
        queue.add(source);
        d[source] = 0;
        while (!queue.isEmpty()) {
            int vertex = queue.remove();
            for (int i = 0; i < n; i++) {
                if (d[i] == -1 && capacity[vertex][i] - flow[vertex][i] > 0) {
                    d[i] = d[vertex] + 1;
                    queue.add(i);
                }
            }
        }
        return d[target] != -1;
    }

    private int dfs(int v, int addedFlow) {
        if (addedFlow == 0 || v == target)
            return addedFlow;
        for (; last[v] < n; last[v]++) {
            int i = last[v];
            if (d[i] == d[v] + 1) {
                int added = dfs(i, Math.min(addedFlow, capacity[v][i] - flow[v][i]));
                flow[v][i] += added;
                flow[i][v] -= added;
                if (added != 0)
                    return added;
            }
        }
        return 0;
    }

    long maxFlow() {
        while (bfs()) {
            Arrays.fill(last, 0);
            while (dfs(source, inf) > 0);
        }
        long result = 0;
        for (int i = 0; i < n; i++) {
            result += flow[source][i];
        }
        return result;
    }
}