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 int MAXN = 310;
const int MAXM = 1000;
template <int MAXN, int MAXM>
struct HLPPMaxFlow {
  struct Edge {
    int to, w;
    Edge *nx, *rec, *nx1;
  } eg[MAXM << 1], *egCnt = eg;
  Edge *hd[MAXN], *hd1[MAXN];
  int g[MAXN], nxNd[MAXN], gap[MAXN], h[MAXN], que[MAXN];
  int ptr;
  long long w[MAXN];
  int s, t, n;
  bool cal = false;
  void init() {
    memset(hd, 0, sizeof(hd));
    memset(hd1, 0, sizeof(hd1));
    memset(w, 0, sizeof(w));
    memset(gap, 0, sizeof(gap));
    memset(h, 0, sizeof(h));
    n = 202, s = 201, t = 202, ptr = 0;
    egCnt = eg;
    cal = false;
  }
  void Cmax(int &a, int b) {
    if (b > a) a = b;
  }
  void Cmin(int &a, int b) {
    if (b < a) a = b;
  }
  inline void AddE(int u, int v, int w) {
    *++egCnt = {v, w, hd[u]};
    hd[u] = egCnt;
    egCnt->rec = egCnt + 1;
    *++egCnt = {u, 0, hd[v]};
    hd[v] = egCnt;
    egCnt->rec = egCnt - 1;
  }
  inline void AddV(int n, int h) {
    nxNd[n] = g[h];
    g[h] = n;
  }
  inline void PushNx1(int u, Edge *j) {
    if (j->w && h[j->to] == h[u] - 1) {
      j->nx1 = hd1[u];
      hd1[u] = j;
    }
  }
  inline void ResetP() {
    while (ptr && !g[ptr]) ptr--;
  }
  inline void BFS() {
    h[t] = 1;
    h[s] = n + 1;
    int qptr = 0;
    que[qptr++] = t;
    for (int i = 0; i < qptr; ++i) {
      if (que[i] == s) continue;
      for (Edge *j = hd[que[i]]; j; j = j->nx) {
        if (h[j->to] || j->w) continue;
        h[j->to] = h[que[i]] + 1;
        que[qptr++] = j->to;
      }
    }
  }
  void HLPP() {
    BFS();
    for (int i = 1; i <= n; ++i) {
      gap[h[i]]++;
      for (Edge *j = hd[i]; j; j = j->nx) PushNx1(i, j);
    }
    for (Edge *j = hd[s]; j; j = j->nx) {
      if (j->w && h[j->to]) {
        AddV(j->to, h[j->to]);
        Cmax(ptr, h[j->to]);
        w[j->to] += j->w;
        j->rec->w += j->w;
        j->w = 0;
      }
    }
    int u = 0;
    while (ptr) {
      u = g[ptr];
      g[ptr] = nxNd[u];
      nxNd[u] = 0;
      if (h[u] > n) continue;
      if (w[u])
        for (Edge *&j = hd1[u]; j; j = j->nx1)
          if (j->w && h[j->to] == h[u] - 1) {
            if (!w[j->to] && j->to != t)
              AddV(j->to, h[j->to]), Cmax(ptr, h[j->to]);
            long long f = std::min<long long>(w[u], j->w);
            w[j->to] += f, w[u] -= f;
            j->rec->w += f, j->w -= f;
            if (!w[u]) break;
          }
      if (w[u]) {
        if (!--gap[h[u]]) {
          for (int i = 1; i <= n; ++i)
            if (h[i] > h[u]) gap[h[i]] = 0, h[i] = n + 1;
          h[u] = n + 1;
          ResetP();
          continue;
        }
        h[u] = n + 1;
        for (Edge *j = hd[u]; j; j = j->nx)
          if (j->w) Cmin(h[u], h[j->to] + 1);
        gap[h[u]]++;
        for (Edge *j = hd[u]; j; j = j->nx)
          PushNx1(u, j), PushNx1(j->to, j->rec);
        AddV(u, h[u]), Cmax(ptr, h[u]);
      }
      ResetP();
    }
  }
  long long operator()() {
    if (!cal) HLPP();
    return w[t];
  }
};
HLPPMaxFlow<MAXN, MAXM> hlpp;
int sum, tsm;
int r[105][105];
int main() {
  hlpp.init();
  int n, m, x, y, c;
  scanf("%d%d", &n, &m);
  hlpp.s = n * 2 + 1;
  hlpp.t = hlpp.n = n * 2 + 2;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &c);
    tsm += c;
    hlpp.AddE(hlpp.s, i, c);
    hlpp.AddE(i, i + n, c);
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &c);
    sum += c;
    hlpp.AddE(i + n, hlpp.t, c);
  }
  if (tsm != sum) {
    printf("NO\n");
    return 0;
  }
  for (int i = 1; i <= m; i++)
    scanf("%d%d", &x, &y), hlpp.AddE(x, y + n, 100000),
        hlpp.AddE(y, x + n, 100000);
  int res = hlpp();
  printf("%s\n", res == sum ? "YES" : "NO");
  if (res == sum) {
    for (int i = 1; i <= n; ++i) {
      for (HLPPMaxFlow<MAXN, MAXM>::Edge *j = hlpp.hd[i]; j; j = j->nx) {
        if (j->to == hlpp.s) continue;
        r[i][j->to - n] = j->rec->w;
      }
    }
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        printf("%d%c", r[i][j], " \n"[j == n]);
      }
    }
  }
}