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;
template <class C>
void mini(C &a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C &a4, C b4) {
  a4 = max(a4, b4);
}
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const long long MAX = 1e5 + 10;
long long n, m;
long long c[MAX];
vector<pair<long long, long long> > d[MAX];
long long res[MAX];
long long s[MAX];
long long par[MAX];
long long pari[MAX];
pair<long long, long long> np = {-1, -1};
long long npi = -1;
bool vis[MAX];
void dfs(long long v, long long gl) {
  vis[v] = 1;
  s[v] = gl;
  for (pair<long long, long long> el : d[v]) {
    if (!vis[el.first]) {
      par[el.first] = v;
      pari[el.first] = el.second;
      dfs(el.first, gl + 1);
      res[el.second] += c[el.first];
      c[v] -= c[el.first];
    } else {
      if (s[v] % 2 == s[el.first] % 2) {
        np = {v, el.first};
        npi = el.second;
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  if (0) cout << fixed << setprecision(6);
  cin >> n >> m;
  for (long long i = (0); i <= ((long long)(n)-1); i++) cin >> c[i];
  for (long long i = (0); i <= ((long long)(m)-1); i++) {
    res[i] = 1;
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    c[a]--;
    c[b]--;
    d[a].push_back({b, i});
    d[b].push_back({a, i});
  }
  dfs(0, 0);
  for (long long i = (0); i <= ((long long)(n)-1); i++) {
    if (0) cout << s[i] << " ";
  }
  if (0) cout << "\n";
  if (c[0] != 0) {
    (c[0]);
    for (long long i = (0); i <= ((long long)(m)-1); i++) {
      if (0) cout << res[i] << " ";
    }
    if (0) cout << "\n";
    if (np.first == -1) {
      cout << "NO\n";
      return 0;
    }
    long long zn = 1;
    long long il = c[0] / 2;
    if (s[np.first] % 2 == 1) {
      zn = -1;
    }
    (npi);
    res[npi] += zn * il;
    (res[npi], npi, np);
    for (long long ak : {np.first, np.second}) {
      (ak, il);
      long long x = zn * -1;
      while (ak != 0) {
        res[pari[ak]] += x * il;
        ak = par[ak];
        x *= -1;
      }
    }
  }
  cout << "YES\n";
  for (long long i = (0); i <= ((long long)(m)-1); i++) {
    cout << res[i] << "\n";
  }
}