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>
#pragma GCC optimize("O2")
using namespace std;
const int MAXN = 1e5 + 10;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const long long INF = 8e18;
const int LOG = 20;
long long pw(long long a, long long b, long long mod) {
  return (!b ? 1
             : (b & 1 ? (a * pw(a * a % mod, b / 2, mod)) % mod
                      : pw(a * a % mod, b / 2, mod)));
}
vector<pair<long long, long long> > G[MAXN];
long long c[MAXN], H[MAXN], mark[MAXN], c2[MAXN], Ans[MAXN];
pair<long long, long long> E[MAXN], P;
long long sum[2];
void DFS(int v, int par = 0) {
  sum[(H[v] % 2)] += c[v];
  mark[v] = 1;
  for (auto y : G[v]) {
    int u = y.first, id = y.second;
    if (u == par) continue;
    if (!mark[u]) {
      H[u] = H[v] + 1;
      DFS(u, v);
      Ans[id] = c2[u];
      c2[v] -= Ans[id];
      c2[u] = 0;
    } else if (H[v] % 2 == H[u] % 2) {
      P = make_pair((1ll) * (H[v] % 2), id);
    }
  }
}
void dfs(int v) {
  mark[v] = 1;
  for (auto y : G[v]) {
    int u = y.first, id = y.second;
    if (!mark[u]) {
      dfs(u);
      Ans[id] = c[u];
      c[v] -= Ans[id];
      c[u] = 0;
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    c2[i] = c[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> E[i].first >> E[i].second;
    G[E[i].first].push_back(make_pair(E[i].second, i));
    G[E[i].second].push_back(make_pair(E[i].first, i));
  }
  sum[0] = sum[1] = 0;
  P = make_pair(0ll, 0ll);
  DFS(1, 0);
  if (P.second == 0) {
    if (sum[0] != sum[1]) return cout << "NO", 0;
    cout << "YES"
         << "\n";
    for (int i = 1; i <= m; i++) {
      cout << Ans[i] << "\n";
    }
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    mark[i] = 0;
  }
  int id = P.second, way = P.first;
  if (way == 1) {
    Ans[id] = (sum[1] - sum[0]) / 2;
    c[E[id].first] -= Ans[id];
    c[E[id].second] -= Ans[id];
  } else {
    Ans[id] = (sum[0] - sum[1]) / 2;
    c[E[id].first] -= Ans[id];
    c[E[id].second] -= Ans[id];
  }
  dfs(1);
  for (int i = 1; i <= n; i++) {
    if (c[i] != 0) return cout << "NO", 0;
  }
  cout << "YES"
       << "\n";
  for (int i = 1; i <= m; i++) {
    cout << Ans[i] << "\n";
  }
  return 0;
}