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 N = 110000;
int head[N], np[N << 1], p[N << 1], id[N << 1], tot;
int n, m;
int c[N];
bool us[N];
int dep[N], fa[N], vis[N];
bool is = 0;
int gtx, gty, gt;
int k[N];
long long b[N];
int a1[N];
long long a2[N];
void dd2(int x) {
  vis[x] = 1;
  for (int u = head[x]; u; u = np[u])
    if (p[u] ^ fa[x])
      if (!vis[p[u]])
        if (id[u] != gt)
          if (us[id[u]]) {
            fa[p[u]] = x;
            dd2(p[u]);
            int nk = -k[p[u]];
            long long nb = c[p[u]] - b[p[u]];
            a1[id[u]] = nk;
            a2[id[u]] = nb;
            b[x] += nb;
            k[x] += nk;
          }
}
long long ans[N];
long long hav[N];
void dd(int x) {
  for (int u = head[x]; u; u = np[u])
    if (fa[p[u]] == x) {
      dd(p[u]);
      ans[id[u]] = c[p[u]] - hav[p[u]];
      hav[x] += ans[id[u]];
    }
}
void dfs(int x) {
  vis[x] = 1;
  for (int u = head[x]; u; u = np[u])
    if (p[u] ^ fa[x]) {
      if (vis[p[u]]) {
        if (dep[p[u]] == dep[x]) {
          is = 1;
          gt = id[u];
          gtx = x;
          gty = p[u];
        }
      } else {
        us[id[u]] = 1;
        fa[p[u]] = x;
        dep[p[u]] = (dep[x] ^ 1);
        dfs(p[u]);
      }
    }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)1; i <= (int)n; i++) scanf("%d", &c[i]);
  for (int i = (int)1; i <= (int)m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    ++tot;
    p[tot] = b;
    np[tot] = head[a];
    head[a] = tot;
    id[tot] = i;
    ++tot;
    p[tot] = a;
    np[tot] = head[b];
    head[b] = tot;
    id[tot] = i;
  }
  dfs(1);
  if (!is) {
    long long s = 0;
    for (int i = (int)1; i <= (int)n; i++)
      if (dep[i])
        s += c[i];
      else
        s -= c[i];
    if (s != 0) {
      puts("NO");
      return 0;
    }
    dd(1);
    if (hav[1] != c[1]) {
      puts("NO");
      return 0;
    }
    puts("YES");
    for (int i = (int)1; i <= (int)m; i++) printf("%lld\n", ans[i]);
  } else {
    memset(fa, 0, sizeof fa);
    memset(vis, 0, sizeof vis);
    k[gty] = 1;
    a1[gt] = 1;
    dd2(gtx);
    long long x = 0;
    x = (c[gtx] - b[gtx]) / 2;
    puts("YES");
    for (int i = (int)1; i <= (int)m; i++) printf("%lld\n", x * a1[i] + a2[i]);
  }
  return 0;
}