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.*;
import java.io.*; 
import java.text.DecimalFormat;

public class Main{
    final long mod = (int)1e9+7, IINF = (long)1e18;
    final int MAX = (int)1e5+1, MX = (int)1e7+1, INF = (int)1e9, root = 3;
    DecimalFormat df = new DecimalFormat("0.0000000000000");
    double eps = 1e-9, PI = 3.141592653589793238462643383279502884197169399375105820974944;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        for(int i = 1, T= (multipleTC)?ni():1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    
    void solve(int TC) throws Exception{
        int n = ni(), m = ni();
        Dinic g = new Dinic(n*2+2);
        int[] a = new int[n], b = new int[n];
        int s1 = 0, s2 = 0;
        for(int i = 0; i< n; i++){
            a[i] = ni();s1+=a[i];
            g.addEdge(0, 2+i, a[i]);
        }
        for(int i = 0; i< n; i++){
            b[i] = ni();s2+=b[i];
            g.addEdge(2+n+i,1,b[i]);
        }
        for(int i = 0; i< n; i++)g.addEdge(2+i,2+n+i,IINF);
        for(int i = 0; i< m; i++){
            int u = ni()-1, v = ni()-1;
            g.addEdge(2+u, 2+n+v, IINF);
            g.addEdge(2+v,2+n+u,IINF);
        }
        if(s1!=s2 || g.dinic(0, 1) != s1)pn("NO");
        else{
            pn("YES");
            long[][] ans = new long[n][n];
            for(int i = 0; i< n; i++){
                for(Dinic.Edge e:g.adj[i+2]){
                    if(e.v==0)continue;
                    ans[i][e.v-2-n] = e.flow;
                }
            }
            for(int i = 0; i< n; i++){
                for(int j = 0; j< n; j++)p(ans[i][j]+" ");pn("");
            }
        }
    }
    
    class Dinic{
        final long IINF = (long)1e18;
        int V;
        int[] level;
        ArrayList<Edge>[] adj;
        public Dinic(int v){
            V = v;
            adj = new ArrayList[V];
            for(int i = 0; i< V; i++)adj[i] = new ArrayList<>();
            level = new int[V];
        }
        
        void addEdge(int u, int v, long w){
            Edge a = new Edge(v,0,w,adj[v].size());
            Edge b = new Edge(u,0,0,adj[u].size());
            adj[u].add(a);
            adj[v].add(b);
        }
        
        long dinic(int s, int t){
            if(s==t)return 0;
            int total = 0;
            while(bfs(s,t)){
                int[] start = new int[V];
                long flow = 0;
                while((flow = sendFlow(s,t,IINF, start)) >0)total+=flow;
            }
            return total;
        }
        
        long sendFlow(int u, int t, long flow, int[] start){
            if(u==t)return flow;
            for(; start[u]<adj[u].size(); start[u]++){
                Edge e = adj[u].get(start[u]);
                if(level[e.v] == level[u]+1 && e.flow<e.c){
                    long cur = Math.min(flow, e.c-e.flow);
                    long tmp_flow = sendFlow(e.v,t, cur, start);
                    if(tmp_flow>0){
                        e.flow+=tmp_flow;adj[e.v].get(e.rev).flow -= tmp_flow;
                        return tmp_flow;
                    }
                }
            }
            return 0;
        }
        
        boolean bfs(int s, int t){
            for(int i = 0; i< V; i++)level[i] = -1;
            level[s] = 0;
            Queue<Integer> q = new LinkedList<>();
            q.add(s);
            while(!q.isEmpty()){
                int x = q.poll();
                for(Edge e:adj[x]){
                    if(level[e.v] == -1 && e.flow<e.c){
                        level[e.v] = level[x]+1;
                        q.add(e.v);
                    }
                }
            }
            return level[t]>=0;
        }
        class Edge{
            int v, rev;
            long flow, c;
            public Edge(int V, long F, long C, int R){
                v = V;flow = F;c = C;rev = R;
            }
        }
    }
    
    int[] sort(int[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        int[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }
    
    long[] sort(long[] a){
        if(a.length==1)return a;
        int mid = a.length/2;
        long[] b = sort(Arrays.copyOfRange(a,0,mid)), c = sort(Arrays.copyOfRange(a,mid,a.length));
        for(int i = 0, j = 0, k = 0; i< a.length; i++){
            if(j<b.length && k<c.length){
                if(b[j]<c[k])a[i] = b[j++];
                else a[i] = c[k++];
            }else if(j<b.length)a[i] = b[j++];
            else a[i] = c[k++];
        }
        return a;
    }

    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

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

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}