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;
int x, y, sz, n, m;
const int N = 3e5;
long long a[N], cs[N];
vector<int> lst;
int st[N], tin[N], mar[N];
map<int, int> mp[N];
vector<pair<int, int> > ed[N];
void dfs(int x, int y) {
  sz++;
  st[sz] = x;
  tin[x] = sz;
  mar[x] = y;
  for (int i = 0; i < ed[x].size(); i++) {
    int to = ed[x][i].first;
    if (mar[to] == 0)
      dfs(to, 3 - y);
    else if (mar[to] == y && lst.size() == 0) {
      for (int j = tin[to]; j <= sz; j++) lst.push_back(st[j]);
      return;
    }
  }
  sz--;
}
void go(int x, int lnk) {
  mar[x] = 1;
  long long need = 0;
  for (int i = 0; i < ed[x].size(); i++) {
    int to = ed[x][i].first;
    if (mar[to] == 1) continue;
    go(to, ed[x][i].second);
    need += cs[ed[x][i].second];
  }
  cs[lnk] = a[x] - need;
}
void chck() {
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < ed[i].size(); j++) {
      int nm = ed[i][j].second;
      a[i] -= cs[nm];
    }
    if (a[i] != 0) {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
  for (int i = 1; i <= m; i++) cout << cs[i] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    mp[x][y] = i;
    mp[y][x] = i;
    ed[x].push_back(make_pair(y, i));
    ed[y].push_back(make_pair(x, i));
  }
  dfs(1, 1);
  for (int i = 1; i <= n; i++) mar[i] = 0;
  if (lst.size() == 0) {
    go(1, 0);
    chck();
  } else {
    int root = lst[0];
    go(root, 0);
    long long need = a[root];
    for (int i = 0; i < ed[root].size(); i++) {
      int nm = ed[root][i].second;
      need -= cs[nm];
    }
    lst.push_back(lst[0]);
    need /= 2;
    int zn = 1;
    for (int i = 0; i + 1 < lst.size(); i++) {
      int nm = mp[lst[i]][lst[i + 1]];
      cs[nm] += need * zn;
      zn *= -1;
    }
    chck();
  }
  return 0;
}