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.ArrayList;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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 {
    private class edge {
        int v, c, f, id;

        public edge(int v, int c, int f, int id) {
            this.v = v;
            this.c = c;
            this.f = f;
            this.id = id;
        }
    }

    private class trace {
        int u, id;

        public trace(int u, int id) {
            this.u = u;
            this.id = id;
        }
    }

    private final int maxN = 205;

    int n, m, s, t, flow, sum;
    ArrayList<edge>[] head;
    int[] q;
    trace[] tr;
    int first, last;
    int[][] res;

    private void Build(InputReader in) {
        n = in.nextInt(); m = in.nextInt();
        s = 0; t = n + n + 1; flow = 0; sum = 0;

        q = new int[maxN];
        tr = new trace[maxN];
        head = new ArrayList[maxN];
        for(int i = 0; i <= t; ++i) head[i] = new ArrayList<>();

        for(int i = 1; i <= n; ++i) {
            int x = in.nextInt();
            head[0].add(new edge(i, x, 0, head[i].size()));
            head[i].add(new edge(0, 0, 0, head[0].size() - 1));
        }

        for(int i = 1; i <= n; ++i) {
            int x = in.nextInt(); sum += x;
            head[i + n].add(new edge(t, x, 0, head[t].size()));
            head[t].add(new edge(i + n, 0, 0, head[i + n].size() - 1));

            head[i].add(new edge(i + n, maxN, 0, head[i + n].size()));
            head[i + n].add(new edge(i, 0, 0, head[i].size() - 1));
        }

        for(int i = 1; i <= m; ++i) {
            int x = in.nextInt(), y = in.nextInt();

            head[x].add(new edge(y + n, maxN, 0, head[y + n].size()));
            head[y + n]. add(new edge(x, 0, 0, head[x].size() - 1));

            head[y].add(new edge(x + n, maxN, 0, head[x + n].size()));
            head[x + n]. add(new edge(y, 0, 0, head[y].size() - 1));
        }


    }

    private boolean FindPath() {
        first = 1; last = 0;
        q[++last] = s;
        for(int i = s; i <= t; ++i)
            tr[i] = new trace(-1, -1);
        tr[s].id = tr[s].u = 0;
        while (first <= last) {
            int u = q[first++], id = 0;
            for(edge e : head[u]) {
                int v = e.v;
                if (tr[v].u == -1 && e.f < e.c) {
                    tr[v].u = u; tr[v].id = id;
                    if (v == t) return true;
                    q[++last] = v;
                }
                ++id;
            }
        }
        return false;
    }

    private void AgumentFlow() {
        int v = t, del = maxN;
        do {
            int u = tr[v].u, id = tr[v].id;
            del = Math.min(del, head[u].get(id).c - head[u].get(id).f);
            v = u;
        } while (v != s);
        v = t;
        do {
            int u = tr[v].u, id = tr[v].id;
            head[u].get(id).f += del;
            head[v].get(head[u].get(id).id).f -= del;
            v = u;
        } while (v != s);
        flow += del;
    }

    private void Find(PrintWriter out) {
        res = new int[maxN][maxN];
for(int i = 1; i <= n; ++i) {
            for(edge e : head[i]) {
                if (e.v <= n) continue;
                res[i][e.v - n] = e.f;
            }
        }

        for(int i = 1; i <= n; ++i) {
            for(int j = 1; j <= n; ++j) out.print(res[i][j] + " ");
            out.println();
        }
    }

    private boolean Check() {
        if (sum != flow) return false;
        for(edge e : head[0])
            if (e.c != e.f) return false;
        return true;
    }

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        Build(in);
        while (FindPath()) AgumentFlow();
        if (Check()) {
            out.println("YES");
            Find(out);
        }
        else out.print("NO");
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        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 int nextInt() {
        return Integer.parseInt(next());
    }

}