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;
const int IINF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int DY[] = {0, 1, 0, -1, 1, -1, -1, 1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long sqr(long long x) { return x * x; }
long long sqr(int x) { return (long long)x * x; }
double sqr(double x) { return x * x; }
long double sqr(long double x) { return x * x; }
mt19937 mmtw(960172);
long long rnd(long long x, long long y) {
  static uniform_int_distribution<long long> d;
  return d(mmtw) % (y - x + 1) + x;
}
const int N = 100179;
int n, m;
vector<pair<int, int> > e[N];
vector<int> e1[N];
int col[N];
int pred[N];
int predI[N];
long long c[N];
vector<pair<int, int> > edges;
long long ans[N];
void dfs(int v, int cc, int p = -1, int pi = -1) {
  if (col[v] != -1) return;
  col[v] = cc;
  pred[v] = p;
  predI[v] = pi;
  if (p != -1) e1[p].push_back(v);
  for (pair<int, int> nv : e[v]) dfs(nv.first, cc ^ 1, v, nv.second);
}
void dfs2(int v) {
  for (int nv : e1[v]) {
    dfs2(nv);
    long long x = c[nv];
    ans[predI[nv]] += x;
    c[nv] -= x;
    c[v] -= x;
  }
}
int main() {
  ios::sync_with_stdio(false);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%lld", &c[i]);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    e[x].push_back({y, i});
    e[y].push_back({x, i});
    edges.push_back({x, y});
  }
  memset(col, -1, sizeof(col));
  dfs(0, 0, -1);
  long long sum[2] = {0, 0};
  for (int i = 0; i < n; ++i) sum[col[i]] += c[i];
  if ((sum[0] - sum[1]) % 2 != 0) {
    cout << "NO\n";
    return 0;
  }
  if (sum[0] != sum[1]) {
    bool ok = false;
    for (int i = 0; i < m; ++i) {
      int x = edges[i].first;
      int y = edges[i].second;
      if (col[x] == col[y]) {
        ok = true;
        ans[i] = (sum[col[x]] - sum[col[x] ^ 1]) / 2;
        c[x] -= ans[i];
        c[y] -= ans[i];
        break;
      }
    }
    if (!ok) {
      cout << "NO\n";
      return 0;
    }
  }
  dfs2(0);
  cout << "YES\n";
  for (int i = 0; i < m; ++i) cout << ans[i] << "\n";
  return 0;
}