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 i64 = long long;
constexpr int maxn(100000);
template <class _Tp>
inline _Tp Abs(const _Tp& v) {
  return v < 0 ? -v : v;
}
template <class _Tp>
inline _Tp Min(const _Tp& x, const _Tp& y) {
  return x < y ? x : y;
}
template <class _Tp>
inline _Tp Max(const _Tp& x, const _Tp& y) {
  return x > y ? x : y;
}
namespace IOManager {
constexpr int FILESZ(131072);
char buf[FILESZ];
const char *ibuf = buf, *tbuf = buf;
struct IOManager {
  inline char gc() {
    return (ibuf == tbuf) &&
                   (tbuf = (ibuf = buf) + fread(buf, 1, FILESZ, stdin),
                    ibuf == tbuf)
               ? EOF
               : *ibuf++;
  }
  template <class _Tp>
  inline operator _Tp() {
    _Tp s = 0u;
    char c = gc(), w = 0;
    for (; c < 48; c = gc()) (c == 45) && (w = 1);
    for (; c > 47; c = gc()) s = (_Tp)(s * 10u + c - 48u);
    return w ? -s : s;
  }
};
}  // namespace IOManager
IOManager::IOManager io;
struct Edge {
  int v, idx;
  Edge* las;
  inline Edge* init(const int to, const int iidx, Edge* const& ls) {
    return v = to, idx = iidx, las = ls, this;
  }
} * las[maxn + 1];
inline void lnk(const int u, const int v, const int idx) {
  static Edge pool[maxn << 1], *alc = pool - 1;
  las[u] = (++alc)->init(v, idx, las[u]);
  las[v] = (++alc)->init(u, idx, las[v]);
}
struct Edge2 {
  int u, v;
} e[maxn + 1];
int ufs[maxn + 1];
inline int Anc(const int _) { return _ == ufs[_] ? _ : ufs[_] = Anc(ufs[_]); }
i64 c[maxn + 1], tc[maxn + 1];
i64 w[maxn + 1];
unsigned char dep[maxn + 1];
void calc(const int now, const int Fa, const int idx) {
  i64& t = c[now];
  for (Edge* o = las[now]; o; o = o->las)
    if (o->v != Fa)
      dep[o->v] = !dep[now], calc(o->v, now, o->idx), t -= w[o->idx];
  w[idx] = t;
  t = 0;
}
int main() {
  const int n = io, m = io;
  for (int i = 1; i <= n; ++i) c[i] = io, ufs[i] = i;
  for (int i = 1; i <= m; ++i)
    if (Anc(e[i].u = io) != Anc(e[i].v = io))
      ufs[ufs[e[i].u]] = ufs[e[i].v], lnk(e[i].u, e[i].v, i);
  memcpy(tc + 1, c + 1, n << 3);
  calc(1, 0, 0);
  memcpy(c + 1, tc + 1, n << 3);
  if (i64 res = *w) {
    if (Abs(res) & 1) return puts("NO"), 0;
    for (int i = 1; i <= m; ++i)
      if (dep[e[i].u] == dep[e[i].v]) {
        if (dep[e[i].u])
          w[i] = -res / 2ll;
        else
          w[i] = res / 2ll;
        c[e[i].u] -= w[i];
        c[e[i].v] -= w[i];
        res = 0;
        break;
      }
    if (res) return puts("NO"), 0;
  }
  calc(1, 0, 0);
  puts("YES");
  for (int i = 1; i <= m; ++i) printf("%lld\n", w[i]);
  return 0;
}