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 mod = (1e9) + 7;
const long long INF = (1e10) + 10;
struct edge {
  int u, v, nxt;
  long long cap, flow;
} e[2010];
struct Dic {
  int head[410], en;
  int q[410];
  int dep[410], cur[410], sta[410];
  void init() {
    memset(head, -1, sizeof(head));
    en = 0;
  }
  void adde1(int u, int v, long long w) {
    e[en].v = v;
    e[en].u = u;
    e[en].cap = w;
    e[en].flow = 0;
    e[en].nxt = head[u];
    head[u] = en++;
  }
  void adde2(int u, int v, long long w) {
    adde1(u, v, w);
    adde1(v, u, 0);
  }
  bool bfs(int s, int t, int n) {
    int frt = 0, tal = 0;
    memset(dep, -1, sizeof(dep[0]) * (n + 1));
    dep[s] = 0;
    q[tal++] = s;
    while (frt < tal) {
      int u = q[frt++];
      for (int i = head[u]; i != -1; i = e[i].nxt) {
        int v = e[i].v;
        if (e[i].cap > e[i].flow && dep[v] == -1) {
          dep[v] = dep[u] + 1;
          if (v == t) return true;
          q[tal++] = v;
        }
      }
    }
    return false;
  }
  long long dinic(int s, int t, int n) {
    long long maxf = 0;
    while (bfs(s, t, n)) {
      for (int i = 0; i < n; i++) cur[i] = head[i];
      int u = s, tal = 0;
      while (cur[s] != -1) {
        if (u == t) {
          long long tp = INF;
          for (int i = tal - 1; i >= 0; i--) {
            tp = min(tp, e[sta[i]].cap - e[sta[i]].flow);
          }
          maxf += tp;
          for (int i = tal - 1; i >= 0; i--) {
            e[sta[i]].flow += tp;
            e[sta[i] ^ 1].flow -= tp;
            if (e[sta[i]].cap == e[sta[i]].flow) tal = i;
          }
          u = e[sta[tal] ^ 1].v;
        } else if (cur[u] != -1 && e[cur[u]].cap > e[cur[u]].flow &&
                   dep[u] + 1 == dep[e[cur[u]].v]) {
          sta[tal++] = cur[u];
          u = e[cur[u]].v;
        } else {
          while (u != s && cur[u] == -1) u = e[sta[--tal] ^ 1].v;
          cur[u] = e[cur[u]].nxt;
        }
      }
    }
    return maxf;
  }
  bool vis[410];
  void cols(int ss) {
    memset(vis, false, sizeof(vis));
    dfs(ss);
  }
  void dfs(int x) {
    vis[x] = true;
    for (int i = head[x]; i != -1; i = e[i].nxt) {
      int v = e[i].v;
      if (!vis[v] && abs(e[i].cap) != abs(e[i].flow)) {
        dfs(v);
      }
    }
  }
};
int a[110], b[110];
int mp[110][110], mv[110][110];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int cntb = 0, cnta = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), cnta += a[i];
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]), cntb += b[i];
  if (cnta != cntb) {
    printf("NO\n");
    return 0;
  }
  Dic ans;
  int ss = 0, tt = n * 4 + 1;
  ans.init();
  for (int i = 1; i <= n; i++) {
    ans.adde2(ss, i, INF);
    ans.adde2(i + n * 3, tt, INF);
    ans.adde2(i, i + n, a[i]);
    ans.adde2(i + n * 2, i + n * 3, b[i]);
    mp[i][i] = ans.en;
    ans.adde2(i + n, i + n * 2, INF);
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    mp[u][v] = ans.en;
    ans.adde2(u + n, v + n * 2, INF);
    mp[v][u] = ans.en;
    ans.adde2(v + n, u + n * 2, INF);
  }
  long long mxf = ans.dinic(ss, tt, tt + 1);
  if (mxf == cnta) {
    printf("YES\n");
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        int id = mp[i][j];
        long long cnt;
        if (id == 0)
          cnt = 0;
        else
          cnt = e[id].flow;
        printf("%lld%c", cnt, j == n ? '\n' : ' ');
      }
    }
  } else
    printf("NO\n");
  return 0;
}