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

Solution:
#include <bits/stdc++.h>
using namespace std;
int stop[300][300];
int waterFlow[300][300];
vector<vector<int>> matrix;
int s, t;
const int inf = 12345678;
int n;
int visited[300];
int part[300];
int flowNext(int v, int mf) {
  if (v == s) {
    return mf;
  }
  int u = part[v];
  if (stop[u][v] <= 0) {
    mf = min(mf, waterFlow[v][u]);
  } else {
    mf = min(mf, stop[u][v] - waterFlow[u][v]);
  }
  mf = flowNext(u, mf);
  if (stop[u][v] <= 0) {
    waterFlow[v][u] -= mf;
  } else {
    waterFlow[u][v] += mf;
  }
  return mf;
}
int breadthFirstSearch() {
  int maxflow = 0;
  while (1) {
    for (int i = 0; i < 2 * n; ++i) visited[i] = 0;
    visited[t] = 0;
    queue<int> q;
    q.push(s);
    visited[s] = 1;
    part[s] = -1;
    bool pushed = false;
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (int i = 0; i < matrix[cur].size(); ++i) {
        int next = matrix[cur][i];
        if (visited[next]) continue;
        if (stop[cur][next] - waterFlow[cur][next] <= 0 &&
            waterFlow[next][cur] <= 0)
          continue;
        visited[next] = 1;
        q.push(next);
        part[next] = cur;
        if (next == t) {
          maxflow += flowNext(t, inf);
          pushed = true;
          break;
        }
      }
      if (pushed) break;
    }
    if (!pushed) break;
  }
  return maxflow;
}
int main() {
  int m, u, v;
  scanf("%d%d", &n, &m);
  s = 2 * n;
  t = 2 * n + 1;
  matrix = vector<vector<int>>(2 * n + 10);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &u);
    stop[s][i] = u;
    sum += u;
    matrix[s].push_back(i);
    matrix[i].push_back(s);
  }
  int check = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &u);
    stop[i + n][t] = u;
    check += u;
    matrix[i + n].push_back(t);
    matrix[t].push_back(i + n);
  }
  if (sum != check) {
    printf("NO\n");
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    stop[i][i + n] = inf;
    matrix[i].push_back(i + n);
    matrix[i + n].push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &u, &v);
    u--;
    v--;
    stop[u][v + n] = inf;
    stop[v][u + n] = inf;
    matrix[u].push_back(v + n);
    matrix[v + n].push_back(u);
    matrix[v].push_back(u + n);
    matrix[u + n].push_back(v);
  }
  check = breadthFirstSearch();
  if (check == sum) {
    printf("YES\n");
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        printf("%d ", waterFlow[i][j + n]);
      }
      printf("\n");
    }
  } else {
    printf("NO\n");
  }
  return 0;
}