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
#include <bits/stdc++.h>
using namespace std;
namespace networks {
class Network {
 public:
  Network(const std::vector<std::pair<int, int>>& flat_edges,
          const std::vector<int>& capacity);
  struct Edge_network_data {
    explicit Edge_network_data() = default;
    Edge_network_data(int from_, int to_, int capacity_, int flow_, int id_,
                      int reverse_id_)
        : from(from_),
          to(to_),
          capacity(capacity_),
          flow(flow_),
          id(id_),
          reverse_id(reverse_id_) {}
    int from, to, capacity, flow, id, reverse_id;
  };
  int max_flow(int source, int sink);
  std::vector<std::vector<int>> edges_ids;
  std::vector<Edge_network_data> data_by_id;
  std::vector<int> augmenting_path_(int source, int sink);
  int additional_flow(const std::vector<int>& path);
  void push_flow(const std::vector<int>& path, int residual_flow);
};
}  // namespace networks
networks::Network::Network(const std::vector<std::pair<int, int>>& flat_edges,
                           const std::vector<int>& capacity) {
  int nodes_count = 0;
  int edges_count = 2 * static_cast<int>(flat_edges.size());
  for (auto [start, end] : flat_edges) {
    nodes_count = std::max(nodes_count, std::max(start, end) + 1);
  }
  edges_ids.resize(nodes_count);
  data_by_id.reserve(edges_count);
  for (int id = 0; id < edges_count; id += 2) {
    auto [start, end] = flat_edges[id / 2];
    edges_ids[start].push_back(id);
    edges_ids[end].push_back(id + 1);
    data_by_id.emplace_back(start, end, capacity[id / 2], 0, id, id + 1);
    data_by_id.emplace_back(end, start, 0, 0, id + 1, id);
  }
}
int networks::Network::max_flow(int source, int sink) {
  for (auto& edge_data : data_by_id) {
    edge_data.flow = 0;
  }
  int flow = 0;
  while (true) {
    auto path = augmenting_path_(source, sink);
    if (path.empty()) {
      break;
    }
    auto residual_flow = additional_flow(path);
    flow += residual_flow;
    push_flow(path, residual_flow);
  }
  return flow;
}
int networks::Network::additional_flow(const std::vector<int>& path) {
  int flow = INT_MAX;
  for (const auto edge_id : path) {
    flow =
        std::min(flow, data_by_id[edge_id].capacity - data_by_id[edge_id].flow);
  }
  return flow;
}
void networks::Network::push_flow(const std::vector<int>& path,
                                  int residual_flow) {
  for (auto edge_id : path) {
    data_by_id[edge_id].flow += residual_flow;
    auto reverse_id = data_by_id[edge_id].reverse_id;
    data_by_id[reverse_id].flow -= residual_flow;
  }
}
std::vector<int> networks::Network::augmenting_path_(int source, int sink) {
  auto nodes_count = static_cast<int>(edges_ids.size());
  std::vector<int> path;
  std::vector<int> ancestors(nodes_count, -1);
  std::queue<int> nodes;
  nodes.push(source);
  while (!nodes.empty()) {
    auto current_node = nodes.front();
    nodes.pop();
    for (auto edge_id : edges_ids[current_node]) {
      auto out_node = data_by_id[edge_id].to;
      if (data_by_id[edge_id].flow == data_by_id[edge_id].capacity) {
        continue;
      }
      if (ancestors[out_node] != -1 || out_node == source) {
        continue;
      }
      ancestors[out_node] = edge_id;
      nodes.push(out_node);
    }
  }
  if (ancestors[sink] != -1) {
    auto current_node = sink;
    while (current_node != source) {
      auto edge_id = ancestors[current_node];
      path.push_back(edge_id);
      current_node = data_by_id[edge_id].from;
    }
  }
  return path;
}
void one_case() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> flat;
  vector<int> capacity(2 * n);
  for (auto& el : capacity) {
    cin >> el;
  }
  for (int i = 0; i < n; ++i) {
    flat.emplace_back(2 * n, i);
  }
  for (int i = 0; i < n; ++i) {
    flat.emplace_back(n + i, 2 * n + 1);
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    flat.emplace_back(a, n + b);
    flat.emplace_back(b, n + a);
    capacity.push_back(1e9);
    capacity.push_back(1e9);
  }
  for (int i = 0; i < n; ++i) {
    flat.emplace_back(i, i + n);
    capacity.push_back(1e9);
  }
  auto total = accumulate(capacity.begin() + n, capacity.begin() + 2 * n, 0);
  auto was = accumulate(capacity.begin(), capacity.begin() + n, 0);
  networks::Network net(flat, capacity);
  auto flow = net.max_flow(2 * n, 2 * n + 1);
  if (flow == total && total == was) {
    cout << "YES\n";
    for (int i = 0; i < n; ++i) {
      vector<int> out(n);
      for (auto edge_id : net.edges_ids[i]) {
        if (edge_id % 2 == 0) {
          auto to = net.data_by_id[edge_id].to - n;
          out[to] = net.data_by_id[edge_id].flow;
        }
      }
      for (auto el : out) {
        cout << el << " ";
      }
      cout << "\n";
    }
  } else {
    cout << "NO\n";
  }
}
int main() {
  int t = 1;
  while (t--) {
    one_case();
  }
  return 0;
}
