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;
const long long maxn = 1e5 + 5;
const long long maxm = 1e3 + 5;
const long long inf = 0x3f3f3f3f3f3f3f3fll;
namespace IO {
const int SIZE = (1 << 20) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = obuf + SIZE - 1;
char _st[55];
int _qr = 0;
inline char gc() {
  return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
          (iS == iT ? EOF : *iS++) : *iS++);
}
inline void qread() {}
template <class T1, class... T2>
inline void qread(T1 &IEE, T2 &...ls) {
  register T1 __ = 0, ___ = 1;
  register char ch;
  while (!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
  do {
    __ = (__ << 1) + (__ << 3) + (ch ^ 48);
  } while (isdigit(ch = gc()));
  __ *= ___;
  IEE = __;
  qread(ls...);
  return;
}
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
  return;
}
inline void putc_(char _x) {
  *oS++ = _x;
  if (oS == oT) flush();
}
inline void qwrite() {}
template <class T1, class... T2>
inline void qwrite(T1 IEE, T2... ls) {
  if (!IEE) putc_('0');
  if (IEE < 0) putc_('-'), IEE = -IEE;
  while (IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
  while (_qr) putc_(_st[_qr--]);
  qwrite(ls...);
  return;
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher;
}  // namespace IO
using namespace IO;
long long n, m;
long long cur = 1;
long long head[maxn], nex[maxn], to[maxn];
long long cap[maxn];
void add(long long u, long long v, long long cp) {
  nex[++cur] = head[u];
  to[cur] = v;
  cap[cur] = cp;
  head[u] = cur;
  nex[++cur] = head[v];
  to[cur] = u;
  cap[cur] = 0;
  head[v] = cur;
  return;
}
long long ptr[maxn], dis[maxn];
queue<long long> q;
bool bfs() {
  for (int i = 0; i <= 2ll * n + 1; i++) {
    ptr[i] = head[i];
    dis[i] = 0;
  }
  q.push(0);
  dis[0] = 1;
  while (!q.empty()) {
    long long fr = q.front();
    q.pop();
    for (int i = head[fr]; i; i = nex[i]) {
      long long t = to[i];
      if (cap[i] == 0 || dis[t] > 0) continue;
      q.push(t);
      dis[t] = dis[fr] + 1;
      if (t == 2ll * n + 1) {
        while (!q.empty()) q.pop();
        return 1;
      }
    }
  }
  return 0;
}
long long dinic(long long now, long long flow) {
  if (now == 2ll * n + 1) return flow;
  long long sumf = 0;
  for (long long &i = ptr[now]; i; i = nex[i]) {
    long long t = to[i];
    if (cap[i] == 0 || dis[t] != dis[now] + 1) continue;
    long long tmpf = dinic(t, min(cap[i], flow));
    sumf += tmpf;
    if (tmpf > 0) {
      cap[i] -= tmpf;
      cap[i ^ 1] += tmpf;
      flow -= tmpf;
      if (flow == 0) return sumf;
    } else if (tmpf == 0)
      dis[t] = -1;
  }
  return sumf;
}
long long a[maxn], b[maxn];
long long ansf = 0;
long long f[105][105];
int main() {
  qread(n, m);
  long long suma = 0, sumb = 0;
  for (int i = 1; i <= n; i++) {
    qread(a[i]);
    suma += a[i];
    add(0, i, a[i]);
  }
  for (int i = 1; i <= n; i++) {
    qread(b[i]);
    sumb += b[i];
    add(i + n, 2ll * n + 1, b[i]);
  }
  for (int i = 1; i <= m; i++) {
    long long ux, vx;
    qread(ux, vx);
    add(ux, vx + n, inf);
    add(vx, ux + n, inf);
  }
  for (int i = 1; i <= n; i++) {
    add(i, i + n, inf);
  }
  if (suma != sumb) {
    puts("NO");
    return 0;
  }
  while (bfs()) ansf += dinic(0, inf);
  if (ansf < sumb) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 1; i <= n; i++) {
    for (int j = head[i]; j; j = nex[j]) {
      if (to[j] == 0) continue;
      f[i][to[j] - n] = cap[j ^ 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      printf("%lld ", f[i][j]);
    }
    puts("");
  }
  return 0;
}