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.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;


public class ProblemE {
    public static void main(String[] args) {
        int testMode = 0;
        String testInput = "1 0\n" +
                "2\n" +
                "1\n";
        /*-------------------------------------------------------------------------------------------------------*/
        FastReader in = new FastReader(testMode == 0 ? System.in : new ByteArrayInputStream(testInput.getBytes()));
        PrintWriter out = new PrintWriter(System.out);
        new ProblemSolver().solve(in, out);
        out.close();
    }
}

class ProblemSolver {
    void solve(FastReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int sa = 0;
        int sb = 0;
        int[] a = new int[n + 1];
        int[] b = new int[n + 1];
        for (int i = 1; i <= n; i++) sa += (a[i] = in.nextInt());
        for (int i = 1; i <= n; i++) sb += (b[i] = in.nextInt());

        //public static Node[] construct(int N, int[] from, int[] to, int[] capacity) {

        int N = 4 * n + 2;
        MaxFlowDinic dinic = new MaxFlowDinic();

        dinic.initGraph(N);
        for (int i = 1; i <= n; i++) {
            dinic.addEdge(0, i, Integer.MAX_VALUE);
            dinic.addEdge(i, n + i, a[i]);
            dinic.addEdge(2 * n + i, 3 * n + i, b[i]);
            dinic.addEdge(3 * n + i, N - 1, Integer.MAX_VALUE);
            dinic.addEdge(n + i, 2 * n + i, Integer.MAX_VALUE);
        }
        for (int i = 0; i < m; i++) {
            int v = in.nextInt();
            int u = in.nextInt();
            dinic.addEdge(n + v, 2 * n + u, Integer.MAX_VALUE);
            dinic.addEdge(n + u, 2 * n + v, Integer.MAX_VALUE);
        }

        if (sa == sb && sa == dinic.findMaxFlow(0, N - 1)) {
            out.println("YES");
            for (int i = 1; i <= n; i++) {
                for (int k = 1; k <= n; k++) {
                    out.print((k == 1 ? "" : " ") + dinic.getEdgeFlow(n + i, 2 * n + k));
                }
                out.println();
            }
            return;
        }

        out.println("NO");
    }
}

class MaxFlowDinic {
    class Edge {
        int to;
        int capacity;
        int flow;
        int reverse;

        public Edge(int to, int capacity, int reverse) {
            this.to = to;
            this.capacity = capacity;
            this.reverse = reverse;
        }
    }

    List<Edge> graph[];
    int[] dist;
    int[] queue;
    int[] ptr;

    public void initGraph(int nodesNum) {
        graph = new List[nodesNum];
        for (int i = 0; i < nodesNum; i++) graph[i] = new ArrayList<Edge>();
        dist = new int[nodesNum];
        queue = new int[nodesNum];
        ptr = new int[nodesNum];
    }

    public void addEdge(int v, int u, int capacity) {
        graph[v].add(new Edge(u, capacity, graph[u].size()));
        graph[u].add(new Edge(v, 0, graph[v].size() - 1));
    }

    boolean bfs(int src, int dest) {
        Arrays.fill(dist, -1);
        dist[src] = 0;
        int last = 0;
        queue[last++] = src;
        for (int i = 0; i < last; i++) {
            int v = queue[i];
            for (Edge e : graph[v]) {
                int u = e.to;
                if (dist[u] < 0 && e.flow < e.capacity) {
                    dist[u] = dist[v] + 1;
                    queue[last++] = u;
                }
            }
        }
        return (dist[dest] >= 0);
    }

    int dfs(int v, int dest, int flow) {
        if (v == dest) return flow;
        for (; ptr[v] < graph[v].size(); ++ptr[v]) {
            Edge e = graph[v].get(ptr[v]);
            int u = e.to;
            if (dist[u] == dist[v] + 1 && e.flow < e.capacity) {
                int res = dfs(u, dest, Math.min(flow, e.capacity - e.flow));
                if (res > 0) {
                    e.flow += res;
                    graph[u].get(e.reverse).flow -= res;
                    return res;
                }
            }
        }
        return 0;
    }

    public int findMaxFlow(int src, int dest) {
        int flow = 0;
        while (bfs(src, dest)) {
            Arrays.fill(ptr, 0);
            while (true) {
                int add = dfs(src, dest, Integer.MAX_VALUE);
                if (add == 0) break;
                flow += add;
            }
        }
        return flow;
    }

    public int getEdgeFlow(int v, int u) {
        for (Edge e : graph[v]) {
            if (e.to == u) return e.flow;
        }
        return 0;
    }
}

class FastReader extends BufferedReader {
    private StringTokenizer st;

    public FastReader(InputStream is) {
        super(new InputStreamReader(is));
    }

    public String nextToken() {
        try {
            while (st == null || !st.hasMoreElements()) {
                st = new StringTokenizer(readLine());
            }
            return st.nextToken();
        } catch (IOException e) {
            return null;
        }
    }

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

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

    public int[] nextArrayInt(int size) {
        int[] ret = new int[size];
        for (int i = 0; i < size; i++) {
            ret[i] = nextInt();
        }
        return ret;
    }
}