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;
int n, m, tot;
int u[200005], v[200005], on_tree[200005], fa[200005], col[200005],
    fath[200005], dep[200005];
long long c[200005], mk[200005];
vector<int> G[200005];
unordered_map<int, unordered_map<int, long long> > val;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    (x *= 10) += ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}
int findf(int x) { return x == fa[x] ? x : fa[x] = findf(fa[x]); }
void kruskal() {
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    if (tot == n - 1) return;
    int uf = findf(u[i]), vf = findf(v[i]);
    if (uf == vf) continue;
    on_tree[i] = 1;
    add_edge(u[i], v[i]);
    tot++;
    fa[uf] = vf;
  }
}
void dfs1(int u, int c_fa, int c_col) {
  col[u] = c_col;
  fath[u] = c_fa;
  dep[u] = dep[c_fa] + 1;
  for (int v : G[u]) {
    if (v == c_fa) continue;
    dfs1(v, u, c_col ^ 1);
    c[u] -= val[u][v];
  }
  val[u][c_fa] = val[c_fa][u] = c[u];
}
void work(int _x, int _y) {
  int x = _x, y = _y;
  int dis = 0, delta = 0, flag = -1;
  if (dep[x] < dep[y]) swap(x, y);
  while (dep[x] > dep[1]) dis++, x = fath[x];
  if (dis & 1)
    delta = -c[1] / 2;
  else
    delta = c[1] / 2;
  x = _x, y = _y;
  if (dep[x] < dep[y]) swap(x, y);
  while (dep[x] > dep[y]) {
    val[x][fath[x]] += flag * delta, val[fath[x]][x] += flag * delta;
    flag = -flag, x = fath[x];
  }
  while (dep[x] > dep[1]) {
    val[x][fath[x]] += flag * delta, val[fath[x]][x] += flag * delta;
    val[y][fath[y]] += flag * delta, val[fath[y]][y] += flag * delta;
    flag = -flag, x = fath[x], y = fath[y];
  }
  val[_x][_y] = val[_y][_x] = delta;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) c[i] = read();
  for (int i = 1; i <= m; i++) u[i] = read(), v[i] = read();
  kruskal();
  dfs1(1, 0, 1);
  if (c[1] == 0) {
    puts("YES");
    for (int i = 1; i <= m; i++) printf("%lld\n", val[u[i]][v[i]]);
    return 0;
  }
  if (c[1] & 1) {
    puts("NO");
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    if (col[u[i]] != col[v[i]] || on_tree[i]) continue;
    puts("YES");
    work(u[i], v[i]);
    for (int i = 1; i <= m; i++) printf("%lld\n", val[u[i]][v[i]]);
    return 0;
  }
  puts("NO");
  return 0;
}