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;
using ld = long double;
using vd = vector<ld>;
using vvd = vector<vd>;
using vi = vector<int>;
using vvii = vector<vector<pair<int, int>>>;
const ld EPS = 1e-9;
inline bool lessPair(ld d1, int i1, ld d2, int i2) {
  return abs(d1 - d2) > EPS ? d1 < d2 : i1 < i2;
}
struct LPSolver {
  int m, n;
  vi B, N;
  vvd D;
  LPSolver(const vvd &A, const vd &b, const vd &c)
      : m(((int)b.size())),
        n(((int)c.size())),
        B(m + 1),
        N(n + 1),
        D(m + 1, vd(n + 1, 0)) {
    for (int i = 0; i < (m); i++) {
      for (int j = 0; j < (n); j++) D[i + 1][j] = A[i][j];
      D[i + 1][n] = b[i];
    }
    for (int i = 0; i < (n); i++) D[0][i] = -c[i];
    for (int i = 0; i < (m + 1); i++) B[i] = -i;
    for (int j = 0; j < (n + 1); j++) N[j] = j;
  }
  void Pivot(int r, int s) {
    for (int i = 0; i < (m + 1); i++)
      if (i != r && ((D[i][s] > EPS) || (D[i][s] < -EPS)))
        for (int j = 0; j < (n + 1); j++)
          if (j != s) D[i][j] -= D[r][j] * D[i][s] / D[r][s];
    for (int j = 0; j < (n + 1); j++)
      if (j != s) D[r][j] /= D[r][s];
    for (int i = 0; i < (m + 1); i++)
      if (i != r) D[i][s] /= -D[r][s];
    D[r][s] = 1.0 / D[r][s];
    swap(B[r], N[s]);
  }
  ld Solve(vector<ld> &x) {
    while (true) {
      int ii = 1, jj = 0;
      for (int i = 1; i <= (m); i++)
        if (lessPair(D[i][n], B[i], D[ii][n], B[ii])) ii = i;
      if (D[ii][n] > -EPS) break;
      for (int j = 0; j < (n); j++)
        if (D[ii][j] < D[ii][jj]) jj = j;
      if (D[ii][jj] > -EPS) return -numeric_limits<ld>::infinity();
      Pivot(ii, jj);
    }
    while (true) {
      int ii = 1, jj = 0;
      for (int j = 0; j < (n); j++)
        if (lessPair(D[0][j], N[j], D[0][jj], N[jj])) jj = j;
      if (D[0][jj] > -EPS) break;
      for (int i = 1; i <= (m); i++)
        if (D[i][jj] > EPS &&
            (D[ii][jj] < EPS ||
             lessPair(D[i][n] / D[i][jj], B[i], D[ii][n] / D[ii][jj], B[ii])))
          ii = i;
      if (D[ii][jj] < EPS) return numeric_limits<ld>::infinity();
      Pivot(ii, jj);
    }
    x.assign(n, 0);
    for (int i = 1; i <= (m); i++)
      if (B[i] >= 0) x[B[i]] = D[i][n];
    return D[0][n];
  }
};
int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, m, u, v, sz;
  cin >> n >> m;
  vi a(n), b(n), c(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  for (int i = 0; i < (n); i++) cin >> b[i];
  vector<vi> mat(n, vi(n, 0));
  for (int i = 0; i < (m); i++) {
    cin >> u >> v;
    u--;
    v--;
    mat[u][v] = mat[v][u] = 1;
  }
  for (int i = 0; i < (n); i++) c[i] = b[i] - a[i];
  if (accumulate(c.begin(), c.end(), 0) != 0) return (cout << "NO\n", 0);
  vvd A;
  vd B, C(n * n);
  for (int i = 0; i < (n); i++) {
    vd l(n * n);
    l[i * n + i] = 1;
    A.push_back(l);
    B.push_back(a[i]);
  }
  for (int i = 0; i < (n); i++) {
    vd l(n * n);
    for (int j = 0; j < (n); j++)
      if (mat[i][j]) l[i * n + j] = 1;
    A.push_back(l);
    B.push_back(a[i]);
  }
  for (int i = 0; i < (n); i++) {
    vd l1(n * n), l2(n * n);
    for (int j = 0; j < (n); j++)
      if (mat[i][j]) {
        l1[i * n + j] = -1;
        l2[i * n + j] = 1;
        l1[j * n + i] = 1;
        l2[j * n + i] = -1;
      }
    l1[i * n + i] = 1;
    l2[i * n + i] = -1;
    A.push_back(l1);
    A.push_back(l2);
    B.push_back(b[i]);
    B.push_back(-b[i]);
  }
  LPSolver LPS(A, B, C);
  vd X;
  int ans = round(-LPS.Solve(X));
  if (((int)X.size()) < n) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (n); j++)
      if (i != j) X[i * n + i] -= X[i * n + j];
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (n); j++) cout << X[i * n + j] << "\n "[j < n - 1];
  return 0;
}