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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/**
 * @author Don Li
 */
public class Traveling {

    static final int INF = 1000;

    int n, m;
    int[] A, B;

    void solve() {
        n = in.nextInt();
        m = in.nextInt();
        A = new int[n];
        B = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            A[i] = in.nextInt();
            sum += A[i];
        }
        int sum2 = 0;
        for (int i = 0; i < n; i++) {
            B[i] = in.nextInt();
            sum2 += B[i];
        }

        if (sum != sum2) {
            out.println("NO");
            return;
        }

        int s = 2 * n, t = s + 1;
        Dinic graph = new Dinic(2 * n + 2);
        for (int i = 0; i < n; i++) graph.addEdge(s, i, A[i]);
        for (int i = 0; i < n; i++) graph.addEdge(n + i, t, B[i]);
        for (int i = 0; i < n; i++) graph.addEdge(i, n + i, INF);
        for (int i = 0; i < m; i++) {
            int u = in.nextInt() - 1, v = in.nextInt() - 1;
            graph.addEdge(u, n + v, INF);
            graph.addEdge(v, n + u, INF);
        }

        if (graph.maxFlow(s, t) == sum) {
            out.println("YES");
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (j > 0) out.print(' ');
                    boolean found = false;
                    for (Edge e : graph.G[i]) {
                        if (j + n == e.to) {
                            out.print(INF - e.cap);
                            found = true;
                        }
                    }
                    if (!found) out.print(0);
                }
                out.println();
            }
        } else {
            out.println("NO");
        }
    }

    public class Dinic {
        static final int INF = Integer.MAX_VALUE / 4;

        int V;
        List<Edge>[] G;

        int[] level; // level for vertices
        int[] iter;  // index of the current edge, previous checked edges can be safely bypassed

        // init the graph represented as adjacent list
        public Dinic(int V) {
            this.V = V;
            G = new List[V];
            for (int i = 0; i < V; i++) G[i] = new ArrayList<>();
            level = new int[V];
            iter = new int[V];
        }

        // add edge as well as corresponding reverse edge to the graph
        public void addEdge(int u, int v, int cap) {
            G[u].add(new Edge(v, cap, G[v].size()));
            G[v].add(new Edge(u, 0, G[u].size() - 1));
        }

        /**
         * find max flow by repeatedly adding augmenting path.
         *
         * @param s source
         * @param t sink
         * @return max flow
         */
        public int maxFlow(int s, int t) {
            int flow = 0;
            while (true) {
                bfs(s); // reconstruct the levels for vertices
                if (level[t] < 0) return flow; // terminate when there's no augmenting path from s to t
                Arrays.fill(iter, 0); // reset search index for outgoing edges for each vertex
                int f;
                while ((f = dfs(s, t, INF)) > 0) { // find augmenting path using the current level & search index
                    flow += f;
                }
            }
        }

        // do BFS to calc the level for vertices start from s
        private void bfs(int s) {
            Arrays.fill(level, -1);
            Queue<Integer> qu = new LinkedList<>();
            qu.offer(s);
            level[s] = 0;
            while (!qu.isEmpty()) {
                int u = qu.poll();
                for (Edge e : G[u]) {
                    int v = e.to;
                    if (e.cap > 0 && level[v] < 0) {
                        level[v] = level[u] + 1;
                        qu.offer(v);
                    }
                }
            }
        }

        // do DFS to find any augmenting path, also use level info to speed up.
        private int dfs(int u, int t, int f) {
            if (u == t) return f;
            while (iter[u] < G[u].size()) {
                Edge e = G[u].get(iter[u]);
                int v = e.to;
                if (e.cap > 0 && level[u] < level[v]) {
                    int d = dfs(v, t, Math.min(f, e.cap));
                    if (d > 0) {
                        e.cap -= d;
                        G[v].get(e.rev).cap += d;
                        return d;
                    }
                }
                iter[u]++;
            }
            return 0;
        }
    }

    static class Edge {
        int to;  // next vertex
        int cap; // residual flow
        int rev; // index of the reverse edge

        public Edge(int to, int cap, int rev) {
            this.to = to;
            this.cap = cap;
            this.rev = rev;
        }
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new Traveling().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

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

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

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

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