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 ll = long long;
using ld = long double;
using namespace std;
const int MAXN = 300001;
vector<pair<int, int>> e[MAXN];
vector<pair<int, int>> e2[MAXN];
int h[MAXN];
ll c[MAXN];
ll c2[MAXN];
ll cc[MAXN];
ll ans[MAXN];
int a[MAXN];
int b[MAXN];
int par[MAXN];
int parid[MAXN];
int upv = -1;
int upu = -1;
int upid = -1;
bool w[MAXN];
bool incyc[MAXN];
void setans(int id, ll val) {
  ans[id] = val;
  c[a[id]] -= val;
  c[b[id]] -= val;
}
bool dfs1(int v, int p, int id, int ch) {
  par[v] = p;
  h[v] = ch;
  parid[v] = id;
  for (auto ed : e[v]) {
    if (!h[ed.first]) {
      e2[v].emplace_back(ed.first, ed.second);
      e2[ed.first].emplace_back(v, ed.second);
      dfs1(ed.first, v, ed.second, ch + 1);
      setans(ed.second, c[ed.first]);
    } else if (h[ed.first] < h[v] && h[ed.first] % 2 == h[v] % 2) {
      upv = v;
      upu = ed.first;
      upid = ed.second;
    }
  }
  return c[v];
}
void dfs2(int v, int p, int block) {
  w[v] = true;
  for (auto ed : e2[v]) {
    if (ed.first != p && ed.first != block && !w[ed.first]) {
      dfs2(ed.first, v, block);
      setans(ed.second, c[ed.first]);
    }
  }
}
int n, m;
void pt() {
  for (int i = 1; i <= n; ++i) {
    if (c[i]) {
      assert(false);
    }
  }
  cout << "YES\n";
  for (int i = 0; i < m; ++i) {
    cout << ans[i] << "\n";
  }
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(20);
  cout.tie(nullptr);
  cin.tie(nullptr);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
    c2[i] = c[i];
  }
  for (int i = 0; i < m; ++i) {
    ans[i] = 0;
    cin >> a[i] >> b[i];
    e[a[i]].emplace_back(b[i], i);
    e[b[i]].emplace_back(a[i], i);
  }
  if (!dfs1(1, 1, 1, 1)) {
    pt();
  }
  if (upv == -1) {
    cout << "NO\n";
    return 0;
  }
  fill(ans, ans + m, 0);
  copy(c2 + 1, c2 + n + 1, c + 1);
  vector<int> cyc = {upv};
  vector<int> edid = {upid};
  int cv = upv;
  while (cv != upu) {
    edid.push_back(parid[cv]);
    cv = par[cv];
    cyc.push_back(cv);
  }
  int cs = cyc.size();
  int k = cs / 2;
  auto at = [&](int x) { return cyc[(x + cs) % cs]; };
  auto eat = [&](int x) { return edid[(x + cs) % cs]; };
  for (int i = 0; i < cs; ++i) {
    dfs2(cyc[i], at(i + 1), at(i - 1));
  }
  for (int v : cyc) {
    cc[v] = c[v];
    incyc[v] = true;
  }
  for (int i = 0; i < 1; ++i) {
    ll s = 0;
    for (int v : cyc) {
      s += cc[v];
    }
    s /= 2;
    for (int j = 0; j < k; ++j) {
      s -= cc[at(j * 2 + i + 1)];
    }
    setans(edid[i], s);
  }
  for (int i = 1; i < cs; ++i) {
    setans(edid[i], c[at(i - 1)]);
  }
  pt();
}