Problem: You are given a connected undirected graph with n vertices and m edges. The vertices are enumerated from 1 to n. 

You are given n integers c1, c2, ..., cn, each of them is between  - n and n, inclusive. It is also guaranteed that the parity of cv equals the parity of degree of vertex v. The degree of a vertex is the number of edges connected to it.

You are to write a weight between  - 2·n2 and 2·n2 (inclusive) on each edge in such a way, that for each vertex v the sum of weights on edges connected to this vertex is equal to cv, or determine that this is impossible.

Input

The first line contains two integers n and m (2 ≤ n ≤ 105, n - 1 ≤ m ≤ 105) — the number of vertices and the number of edges.

The next line contains n integers c1, c2, ..., cn ( - n ≤ ci ≤ n), where ci is the required sum of weights of edges connected to vertex i. It is guaranteed that the parity of ci equals the parity of degree of vertex i.

The next m lines describe edges of the graph. The i-th of these lines contains two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi), meaning that the i-th edge connects vertices ai and bi.

It is guaranteed that the given graph is connected and does not contain loops and multiple edges.

Output

If there is no solution, print "NO".

Otherwise print "YES" and then m lines, the i-th of them is the weight of the i-th edge wi ( - 2·n2 ≤ wi ≤ 2·n2).

Examples

Input

3 3
2 2 2
1 2
2 3
1 3


Output

YES
1
1
1


Input

4 3
-1 0 2 1
1 2
2 3
3 4


Output

YES
-1
1
1


Input

6 6
3 5 5 5 1 5
1 4
3 2
4 3
4 5
3 5
5 6


Output

YES
3
5
3
-1
-3
5


Input

4 4
4 4 2 4
1 2
2 3
3 4
4 1


Output

NO

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 14;
int n, m;
struct Edge {
  int v, u;
  long long w;
  int o(int x) { return x == v ? u : v; }
} e[maxn];
vector<Edge*> g[maxn];
vector<Edge*> cyc, cur;
Edge* par[maxn];
int col[maxn];
long long c[maxn];
int mark[maxn];
bool dfs(int v = 0, int c = 1) {
  col[v] = c;
  mark[v] = cur.size() + 1;
  for (auto e : g[v]) {
    int u = e->o(v);
    if (!col[u]) {
      par[u] = e;
      cur.push_back(e);
      if (dfs(u, 3 - c)) return 1;
      cur.pop_back();
    } else if (col[u] == c) {
      cyc.push_back(e);
      while (!mark[u]) cyc.push_back(par[u]), u = par[u]->o(u);
      while (u != v) {
        cyc.push_back(cur[mark[u] - 1]), u = cur[mark[u] - 1]->o(u);
      }
      return 1;
    }
  }
  mark[v] = 0;
  return 0;
}
void fix(int v, int p = -1) {
  mark[v] = 1;
  for (auto e : g[v]) {
    int u = e->o(v);
    if (!mark[u]) {
      fix(u, v);
      e->w = c[u];
      c[v] -= c[u];
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < m; i++) {
    cin >> e[i].v >> e[i].u;
    e[i].v--, e[i].u--;
    g[e[i].v].push_back(&e[i]);
    g[e[i].u].push_back(&e[i]);
  }
  int root = 0;
  bool hasCy = 0;
  if (dfs()) {
    root = -1;
    for (auto x : {cyc[0]->v, cyc[0]->u})
      for (auto y : {cyc.back()->v, cyc.back()->u})
        if (x == y) root = x;
    assert(root != -1);
    hasCy = 1;
  }
  memset(mark, 0, sizeof mark);
  fix(root);
  if (hasCy) {
    long long x = c[root] / 2;
    c[root] = 0;
    for (int i = 0; i < cyc.size(); i++) cyc[i]->w += (i & 1 ? -x : x);
  }
  if (!c[root]) {
    cout << "YES\n";
    for (int i = 0; i < m; i++) cout << e[i].w << '\n';
  } else
    cout << "NO\n";
}