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.*;
import java.util.*;

public class Soldiers {
  static int n;

  public static boolean bfs(int[][] graph, int[] previous, int[] maxFlow, int[] initial, int[] ending) {
    Arrays.fill(previous, -1);
    Arrays.fill(maxFlow, -1);

    int source = 0;
    int sink = 2 * n + 1;

    Queue<Integer> queue = new LinkedList<>();
    queue.add(source);
    maxFlow[source] = Integer.MAX_VALUE;

    boolean foundSink = false;

    while (!queue.isEmpty()) {
        int location = queue.remove();
        int flow = maxFlow[location];

        foundSink |= (location == sink);

        for (int nextLocation = 0; nextLocation < graph.length; nextLocation++) {
            // int capacity =  graph[location][nextLocation] != 0 ? 1 : 0;
            // if(capacity > 0)         {
            //   capacity = Math.min(
            //     initial[getOriginal(location)], Math.max(
            //       ending[getOriginal(nextLocation)] - initial[getOriginal(nextLocation)], 0
            //     )
            //   ); 
            // }
            int capacity = graph[location][nextLocation];
            // Only go to unvisited nodes with valid edges
            if (previous[nextLocation] == -1 && capacity > 0) {
                previous[nextLocation] = location;
                maxFlow[nextLocation] = Math.min(flow, capacity);

                queue.add(nextLocation);
            }
        }
    }

    return foundSink;
  }

  public static int getOriginal(int node) {
  if (node > n) {
      return node - n;
    }
    return node;
  }

  public static int fordFulkerson(int[][] graph, int[] ending, int[] starting, int diffs) {
    // The max flow to every node.
    int[] maxFlow = new int[graph.length];
    int[] previous = new int[graph.length];

    int source = 0;
    int sink = 2 * n + 1;

    // While there's a path from source to sink
    while (bfs(graph, previous, maxFlow, starting, ending)) {
        // Find the maximum amount of flow that can reach the sink
        int currentFlow = maxFlow[sink];

        // Update all the edge capacities
        int node = sink;
        int end = previous[sink];
        int start = -1;
        while (node != source) {
            int previousNode = previous[node];
            // Update the residual graph
            graph[previousNode][node] -= currentFlow;
            graph[node][previousNode] += currentFlow;

            start = node;
            node = previousNode;
        }

        // update configuration
        int prev_orig = getOriginal(start);
        boolean prev_equal = starting[prev_orig] == ending[prev_orig];
        starting[prev_orig] -= currentFlow;

        int node_orig = getOriginal(end);
        boolean node_equal = starting[node_orig] == ending[node_orig];
        starting[node_orig] += currentFlow;

        // track state changes
        if(prev_equal && starting[prev_orig] != ending[prev_orig]) {
          diffs ++;
        } else if (!prev_equal && starting[prev_orig] == ending[prev_orig]) {
          diffs --;
        }
        if(node_equal && starting[node_orig] != ending[node_orig]) {
          diffs ++;
        } else if (!node_equal && starting[node_orig] == ending[node_orig]) {
          diffs --;
        }
    }
    return diffs;
  }

  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    n = Integer.parseInt(st.nextToken()); // num cities
    int m = Integer.parseInt(st.nextToken()); // num roads

    int[] initial = new int[n + 2];
    initial[0] = Integer.MAX_VALUE / 2;
    st = new StringTokenizer(br.readLine());
    for(int i = 1; i <= n; i ++) {
      initial[i] = Integer.parseInt(st.nextToken());
    }
    initial[n + 1] = Integer.MAX_VALUE / 2;

    int[] ending = new int[n + 2];
    int diffs = 0;
    st = new StringTokenizer(br.readLine());
    ending[0] = Integer.MAX_VALUE / 2;
    for(int i = 1; i <= n; i ++) {
      ending[i] = Integer.parseInt(st.nextToken());
      // track initial differences
      if(ending[i] != initial[i]) {
        diffs ++;
      }
    }
    ending[n + 1] = Integer.MAX_VALUE / 2;

    // with dummy source/sink nodes
    int[][] graph = new int[n * 2 + 2][n * 2 + 2]; 
    for(int i = 0; i < m; i ++) {
      st = new StringTokenizer(br.readLine());
      int city1 = Integer.parseInt(st.nextToken());
      int city2 = Integer.parseInt(st.nextToken());

      // need to make a copy of graph for starting, ending states
      int city1_copy = city1 + n;
      int city2_copy = city2 + n;
      // flow in each direction bounded by # soldiers in the city

      graph[city1][city2_copy] = Math.min(initial[city1], ending[city2]);
      graph[city2][city1_copy] = Math.min(initial[city2], ending[city1]);
    }
    for(int i = 1; i <= n; i ++) {
      // how much flow can you send through dummy source/sink?
      graph[0][i] = initial[i];
      graph[i + n][n * 2 + 1] = ending[i];
      // how much flow can you send from initial to final states of same city?
      graph[i][n + i] = initial[i];
    }

    // printArr(graph);
    // System.out.println();
    fordFulkerson(graph, ending, initial, diffs);

    boolean match = true;
    for(int i = 1; i <= n && match; i ++) {
      if(initial[i] != ending[i]) {
        match = false;
      }
    }
    if ( match) {

      System.out.println("YES");
      // int[][] paths = {
      //   {1, 0, 0, 0},
      //   {2, 0, 0, 0},
      //   {0, 5, 1, 0},
      //   {0, 0, 2, 1}};
      // printArr(graph);
      int[][] paths = new int[n][n];
      for(int i = 1; i <= n; i ++) {
        // for(int j = 1; j <= n; j ++) {
        //   int i_copy = i + n;
        //   int j_copy = j + n;
        //   paths[i-1][j-1] = graph[i][j_copy] - graph[j][i_copy] + graph[j_copy][i] - graph[i_copy][j];
        // }
        int sum = 0;
        for(int j = n + 1; j <= n * 2; j ++) {
          paths[j - 1 - n][i - 1] = graph[i + n][j - n];
          sum += graph[i + n][j - n];
        }
        if(sum != ending[i]) {
          paths[i -1][i-1] =  ending[i] - sum;

        }
      }
      // for(int i = 1; i <= n; i ++) {
      //   // backwards flow describes how much was actually sent
      //   paths[i-1][i-1] = graph[i][i + n];

      // }
      // System.out.println();
      printArr(paths);

    } else {

      System.out.println("NO");
    }

  }

  static void printArr(int[] arr) {
    System.out.print(arr[0]);
    for(int i = 1; i < arr.length; i ++) {
      System.out.print(" " + arr[i]);
    }
    System.out.println();
  }

  static void printArr(int[][] arr) {
    for(int i = 0; i < arr.length; i ++) {
      printArr(arr[i]);
    }
  }
}
