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;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) {
  long long z = y;
  while (x % y != 0) {
    z = x % y;
    x = y;
    y = z;
  }
  return z;
}
vector<pair<int, int> > mp[100005];
int C[100005], U[100005], V[100005], dp[100005], fa[100005], A, B, AB,
    efa[100005];
long long sv[100005];
long long wt[100005];
bool vis[100005];
void dfs(int x, int pa) {
  vis[x] = 1;
  dp[x] = dp[pa] + 1;
  fa[x] = pa;
  for (auto cp : mp[x])
    if (cp.first != pa) {
      int c = cp.first, eid = cp.second;
      if (vis[c]) {
        if (dp[x] > dp[c] && (dp[x] - dp[c]) % 2 == 0) {
          A = x;
          B = c;
          AB = eid;
        }
      } else {
        efa[c] = eid;
        dfs(c, x);
        wt[eid] = C[c] - sv[c];
        sv[x] += wt[eid];
      }
    }
}
void fmain(int ID) {
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", C + i);
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    mp[u].push_back({v, i});
    mp[v].push_back({u, i});
    U[i] = u;
    V[i] = v;
  }
  dfs(1, 0);
  if (abs(C[1] - sv[1]) % 2 == 1) etp();
  if (abs(C[1] - sv[1]) != 0) {
    if (A == 0) etp();
    int fg = (dp[B] - dp[1]) & 1 ? -1 : 1;
    long long w = (C[1] - sv[1]) / 2 * fg;
    wt[AB] = w;
    long long tw = w;
    for (int i = A; i != B; i = fa[i]) {
      wt[efa[i]] -= tw;
      tw *= -1;
    }
    tw = w + w;
    for (int i = B; i != 1; i = fa[i]) {
      wt[efa[i]] -= tw;
      tw *= -1;
    }
  }
  puts("YES");
  for (int(i) = 1; (i) <= (int)(m); (i)++) printf("%lld\n", wt[i]);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}