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.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Flow {


    private static final int INF = Integer.MAX_VALUE;


    private static int pushflow(int s, int v, int mf, int[] par, int[][] cap, int[][] flow) {
        if(v == s) {
            return mf;
        }
        int u = par[v];
        if(cap[u][v]<=0) {
            mf = Math.min(mf, flow[v][u]);
        } else {
            mf = Math.min(mf, cap[u][v] - flow[u][v]);
        }
        mf = pushflow(s, u, mf, par, cap, flow);
        if(cap[u][v]<=0){
            flow[v][u] -= mf;
        } else {
            flow[u][v] += mf;
        }
        return mf;
    }

    private static int bfs(int s, int t, int[][] cap, int[][] flow, int n, ArrayList<ArrayList<Integer>> adj) {
        int[] vis = new int[300];
        int[] par = new int[300];
        int maxflow = 0;
        while(true){
            for(int i=0;i<2*n;++i) vis[i] = 0;
            vis[t] = 0;
            Queue<Integer> q = new LinkedList<>();
            q.add(s);
            vis[s] = 1;
            par[s] = -1;
            boolean pushed = false;
            while(!q.isEmpty()){
                int cur = q.remove();
                for(int i = 0;i < adj.get(cur).size();++i){
                    int next = adj.get(cur).get(i);
                    if(vis[next] != 0) continue;
                    if(cap[cur][next] - flow[cur][next] <= 0
                            && flow[next][cur] <= 0)continue;
                    vis[next] = 1;
                    q.add(next);
                    par[next] = cur;
                    if(next == t) {
                        maxflow += pushflow(s, t, INF, par, cap, flow);
                        pushed = true;
                        break;
                    }
                }
                if(pushed)break;
            }
            if(!pushed)break;
        }
        return maxflow;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] cap = new int[300][300];
        int[][] flow = new int[300][300];
        //vector<vector<int> > adj;
        int s, t;
        int u, v;
        int n = sc.nextInt();
        int m = sc.nextInt();
        s = 2*n;
        t = 2*n+1;
        ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
        for (int i = 0; i < 2 * n + 10; i++) {
            adj.add(new ArrayList<>());
        }
        //adj = vector<vector<int> > (2*n+10);
        int sum = 0;
        for(int i=0;i<n;++i){
            u = sc.nextInt();
            cap[s][i] = u;
            sum += u;
            adj.get(s).add(i);
            adj.get(i).add(s);
        }
        int check = 0;
        for(int i=0;i<n;++i){
            u = sc.nextInt();
            cap[i+n][t] = u;
            check += u;
            adj.get(i + n).add(t);
            adj.get(t).add(i+n);
        }
        if(sum != check) {
            System.out.println("NO");
        } else {
            for (int i = 0; i < n; ++i) {
                cap[i][i + n] = INF;
                adj.get(i).add(i + n);
                adj.get(i + n).add(i);
            }
            for (int i = 0; i < m; ++i) {
                u = sc.nextInt();
                v = sc.nextInt();
                u--;
                v--;
                cap[u][v + n] = INF;
                cap[v][u + n] = INF;
                adj.get(u).add(v + n);
                adj.get(v + n).add(u);
                adj.get(v).add(u + n);
                adj.get(u + n).add(v);
            }
            check = bfs(s, t, cap, flow, n, adj);
            if (check == sum) {
                System.out.println("YES");
                for (int i = 0; i < n; ++i) {
                    for (int j = 0; j < n; ++j) {
                        System.out.print(flow[i][j + n] + " ");
                    }
                    System.out.println();
                }
            } else {
                System.out.println("NO");
            }
        }
    }

}