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>
int CH, NEG;
template <typename TP>
inline void read(TP& ret) {
  ret = NEG = 0;
  while (CH = getchar(), CH < '!')
    ;
  if (CH == '-') NEG = true, CH = getchar();
  while (ret = ret * 10 + CH - '0', CH = getchar(), CH > '!')
    ;
  if (NEG) ret = -ret;
}
int star[100010LL], e[3][100010LL << 1], te = 1;
inline void AddEdge(int u, int v, int w) {
  te++;
  e[0][te] = v;
  e[1][te] = star[u];
  star[u] = te;
  e[2][te] = w;
  te++;
  e[0][te] = u;
  e[1][te] = star[v];
  star[v] = te;
  e[2][te] = w;
}
int n, m;
long long c[100010LL], cc[100010LL], ans[100010LL];
int pre[100010LL];
bool col[100010LL], vis[100010LL];
bool odd = false;
int eu, ev, ei;
void dfs(int u = 1) {
  vis[u] = true;
  for (int p = star[u], v; p; p = e[1][p])
    if (v = e[0][p], !vis[v]) {
      pre[v] = p;
      col[v] = col[u] ^ 1;
      dfs(v);
      cc[u] -= (ans[e[2][p]] = cc[v]);
    } else if (col[u] == col[v])
      odd = true, eu = u, ev = v, ei = e[2][p];
}
void dfs2(int u) {
  vis[u] = false;
  for (int p = star[u], v; p; p = e[1][p])
    if (v = e[0][p], vis[v] && (col[v] ^ col[u]) && e[2][p] != ei) {
      pre[v] = p;
      dfs2(v);
      c[u] -= (ans[e[2][p]] = c[v]);
    }
}
int main() {
  int i, a, b;
  long long delta, sig;
  read(n), read(m);
  for (i = (1); i <= (n); i++) read(c[i]), cc[i] = c[i];
  for (i = (1); i <= (m); i++) read(a), read(b), AddEdge(a, b, i);
  dfs();
  if (cc[1] == 0) {
    puts("YES");
    for (i = (1); i <= (m); i++) printf("%lld\n", ans[i]);
    goto END;
  }
  if (!odd) {
    puts("NO");
    goto END;
  }
  memset(ans, 0, sizeof ans);
  dfs2(eu);
  delta = c[eu] / 2LL;
  sig = -1LL;
  while (ev != eu) {
    ans[e[2][pre[ev]]] += sig * delta;
    ev = e[0][pre[ev] ^ 1];
    sig *= -1LL;
  }
  ans[ei] += delta;
  puts("YES");
  for (i = (1); i <= (m); i++) printf("%lld\n", ans[i]);
END:
  getchar(), getchar();
  return 0;
}