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;
long long ans[100010];
struct Edge {
  int v, nxt;
} e[200010];
int tot = 1;
int first[100010];
void build(int u, int v) {
  e[++tot] = (Edge){v, first[u]};
  first[u] = tot;
  return;
}
long long c[100010];
int dep[100010];
int sta[100010], head;
bool flag;
int S, x[100010], cnt;
void dfs(int u, int lst) {
  dep[u] = dep[lst] + 1;
  for (int i = first[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == lst) continue;
    if (!dep[v]) {
      sta[++head] = i / 2;
      dfs(v, u);
      head--;
    } else if (!flag && (dep[u] - dep[v]) % 2 == 0) {
      cnt = dep[u] - dep[v] + 1;
      for (int j = 1; j < cnt; j++) x[j] = sta[head - j + 1];
      x[cnt] = i / 2;
      S = u;
      flag = true;
    }
  }
  return;
}
bool vis[100010];
void solve(int u) {
  vis[u] = true;
  for (int i = first[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (vis[v]) continue;
    solve(v);
    ans[i / 2] -= c[v];
    c[u] -= c[v];
  }
  return;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &c[i]);
    c[i] = -c[i];
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    build(u, v);
    build(v, u);
  }
  dfs(1, 0);
  if (flag) {
    solve(S);
    for (int i = 1; i <= cnt; i++)
      if (i & 1)
        ans[x[i]] -= c[S] / 2;
      else
        ans[x[i]] += c[S] / 2;
    printf("YES\n");
    for (int i = 1; i <= m; i++) printf("%I64d\n", ans[i]);
  } else {
    solve(1);
    if (c[1])
      printf("NO\n");
    else {
      printf("YES\n");
      for (int i = 1; i <= m; i++) printf("%I64d\n", ans[i]);
    }
  }
  return 0;
}