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>
#pragma comment(linker, '/STACK:200000')
const int INF = 1e9 + 7;
const double EPS = 1e-9;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int N = 1e5 + 1000;
using namespace std;
struct edge {
  int a, b, cap, flow;
  edge() { a = b = cap = flow = 0; }
  edge(int aa, int bb, int c) {
    a = aa;
    b = bb;
    cap = c;
    flow = 0;
  }
};
vector<edge> e;
vector<int> g[N];
int csz, d[N], ptr[N], q[N], qs, qt, st, ed;
map<pair<int, int>, int> e_id;
void add_edge(int a, int b, int c) {
  g[a].emplace_back((int)e.size());
  e_id[make_pair(a, b)] = (int)e.size();
  e.emplace_back(edge(a, b, c));
  g[b].emplace_back((int)e.size());
  e.emplace_back(edge(b, a, 0));
}
bool Bfs() {
  qs = qt = 0;
  for (int i = 0; i <= csz; i++) d[i] = -1;
  d[st] = 0;
  q[qt++] = st;
  while (qs < qt && d[ed] == -1) {
    int v = q[qs++];
    for (auto id : g[v]) {
      int to = e[id].b;
      if (d[to] == -1 && (e[id].cap > e[id].flow))
        d[to] = d[v] + 1, q[qt++] = to;
    }
  }
  return (d[ed] != -1);
}
int Dfs(int v, int flow) {
  if (!flow) return 0;
  if (v == ed) return flow;
  for (; ptr[v] < (int)g[v].size(); ptr[v]++) {
    int id = g[v][ptr[v]], to = e[id].b;
    if (d[to] != d[v] + 1) continue;
    int push = Dfs(to, min(flow, e[id].cap - e[id].flow));
    if (push) {
      e[id].flow += push;
      e[id ^ 1].flow -= push;
      return push;
    }
  }
  return 0;
}
int Get() {
  int res = 0;
  while (1) {
    if (!Bfs()) break;
    for (int i = 0; i <= csz; i++) ptr[i] = 0;
    while (int cur = Dfs(st, INF)) res += cur;
  }
  return res;
}
int idb[N], ida[N];
int Id1(int x) {
  if (!ida[x]) return ida[x] = csz++;
  return ida[x];
}
int Id2(int x) {
  if (!idb[x]) return idb[x] = csz++;
  return idb[x];
}
int a[N], b[N], n, m, ans[333][333], aa[N];
bool Check() {
  for (int i = 1; i <= n; i++) aa[i] = a[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) aa[i] -= ans[i][j], aa[j] += ans[i][j];
  for (int i = 1; i <= n; i++)
    if (aa[i] != b[i]) return 0;
  return 1;
}
int main() {
  cin.tie(0);
  ios_base ::sync_with_stdio(0);
  st = csz++;
  ed = csz++;
  int sum = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  for (int j = 1; j <= n; j++) cin >> b[j];
  bool ok = 1;
  for (int i = 1; i <= n; i++) ok &= (a[i] == b[i]);
  if (ok) {
    cout << "YES\n";
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) cout << (i == j ? a[i] : 0) << " \n"[j == n];
    return 0;
  }
  int x, y;
  for (int i = 1; i <= n; i++) add_edge(st, Id1(i), a[i]);
  for (int i = 1; i <= n; i++) add_edge(Id2(i), ed, b[i]);
  for (int i = 1; i <= n; i++) add_edge(Id1(i), Id2(i), a[i]);
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    add_edge(Id1(x), Id2(y), b[y]);
    add_edge(Id1(y), Id2(x), a[y]);
  }
  if (Get() == sum) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        int f = Id1(i), s = Id2(j);
        if (e_id.count(make_pair(f, s)))
          ans[i][j] = e[e_id[make_pair(f, s)]].flow;
        else
          ans[i][j] = 0;
      }
    if (Check()) {
      cout << "YES\n";
      for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++) cout << ans[i][j] << " \n"[j == n];
    } else
      cout << "NO\n";
  } else
    cout << "NO\n";
  return 0;
}