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 PYTHON3):

Solution:
import sys

cap = [[0 for i in range(300)] for j in range(300)]
flow = [[0 for i in range(300)] for j in range(300)]
inf = 99999999
vis = [0] * 300
par = [0] * 300

def pushflow(v, mf, s):
    if (v == s):
        return mf
    
    u = par[v]
    if (cap[u][v] <= 0):
        mf = min(mf, flow[v][u])
    else:
        mf = min(mf, cap[u][v] - flow[u][v])
    
    mf = pushflow(u, mf, s)
    if (cap[u][v] <= 0):
        flow[v][u] -= mf
    else:
        flow[u][v] += mf
        
    return mf
    
def bfs(n, m, s, t, adj):
    maxflow = 0
    while (1):
        for i in range(2*n):
            vis[i] = 0
        vis[t] = 0
        q = []
        q.append(s)
        vis[s] = 1
        par[s] = -1
        pushed = False
        
        while (len(q) != 0):
            cur = q.pop()
            for i in range(len(adj[cur])):
                nex = adj[cur][i]
                if (vis[nex]):
                    continue
                if (cap[cur][nex] - flow[cur][nex] <= 0 and flow[nex][cur] <= 0):
                    continue
                vis[nex] = 1
                q.append(nex)
                par[nex] = cur
                if nex == t:
                    maxflow += pushflow(t, inf, s)
                    pushed = True
                    break
                
            if pushed:
                break
        if (not pushed):
            break
    return maxflow
    
def main():
    data = [line.rstrip().split() for line in sys.stdin.readlines()]
    data = [[int(x) for x in row] for row in data]
    
    n = data[0][0]
    m = data[0][1]
    
    s = 2*n
    t = 2*n + 1
    adj = [[] for i in range (2*n+10)]
    summing = 0
    for i in range(n):
        u = data[1][i]
        cap[s][i] = u
        summing += u
        adj[s].append(i)
        adj[i].append(s)
    
    check = 0
    for i in range(n):
        u = data[2][i]
        cap[i+n][t] = u
        check += u
        adj[i + n].append(t)
        adj[t].append(i + n)
    if (summing != check):
        print("NO")
        return
    for i in range(n):
        cap[i][i + n] = inf
        adj[i].append(i+n)
        adj[i+n].append(i)
    for i in range(m):
        u = data[i + 3][0]
        v = data[i + 3][1]
        u -= 1
        v -= 1
        cap[u][v + n] = inf
        cap[v][u + n] = inf
        adj[u].append(v + n)
        adj[v + n].append(u)
        adj[v].append(u + n)
        adj[u + n].append(v)
    check = bfs(n, m, s, t, adj)
    if (check == summing):
        print("YES")
        for i in range(n):
            for j in range(n):
                print(flow[i][j + n], end =" ")
            print('\n', end="")
    else:
        print("NO")

main()