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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Div1_453D {

	static long[] val;

	static ArrayList<Integer>[] aList;
	static ArrayList<Integer>[] eList;

	static int[] color;

	static int[] pV;
	static int[] pE;

	static int cStart;
	static int cEnd;
	static int cEdge;

	static long[] eV;

	static boolean[] visited;

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer inputData = new StringTokenizer(reader.readLine());
		int nV = Integer.parseInt(inputData.nextToken());
		int nE = Integer.parseInt(inputData.nextToken());
		val = new long[nV];
		inputData = new StringTokenizer(reader.readLine());
		for (int i = 0; i < nV; i++) {
			val[i] = Integer.parseInt(inputData.nextToken());
		}

		aList = new ArrayList[nV];
		eList = new ArrayList[nV];
		for (int i = 0; i < nV; i++) {
			aList[i] = new ArrayList<>();
			eList[i] = new ArrayList<>();
		}
		for (int i = 0; i < nE; i++) {
			inputData = new StringTokenizer(reader.readLine());
			int a = Integer.parseInt(inputData.nextToken()) - 1;
			int b = Integer.parseInt(inputData.nextToken()) - 1;
			aList[a].add(b);
			aList[b].add(a);
			eList[a].add(i);
			eList[b].add(i);
		}

		color = new int[nV];
		Arrays.fill(color, -1);

		pV = new int[nV];
		pE = new int[nV];

		color[0] = 0;
		boolean isBipartite = color(0);

		eV = new long[nE];

		visited = new boolean[nV];
		if (isBipartite) {
			gDetermine(0);
			if (val[0] == 0) {
				printer.println("YES");
				for (int i = 0; i < nE; i++) {
					printer.println(-eV[i]);
				}
			} else {
				printer.println("NO");
			}
		} else {
			gDetermine(cEnd);
			long delta = -val[cEnd] / 2;
			int cV = cEnd;
			while (cV != cStart) {
				eV[pE[cV]] += delta;
				cV = pV[cV];
				delta = -delta;
			}
			eV[cEdge] += delta;
			printer.println("YES");
			for (int i = 0; i < nE; i++) {
				printer.println(-eV[i]);
			}
		}
		printer.close();
	}

	static boolean color(int cV) {
		for (int aI = 0; aI < aList[cV].size(); aI++) {
			int aV = aList[cV].get(aI);
			int aE = eList[cV].get(aI);
			if (color[aV] == -1) {
				color[aV] = color[cV] ^ 1;
				pV[aV] = cV;
				pE[aV] = aE;
				if(!color(aV)) {
					return false;
				}
			} else {
				if (color[aV] == color[cV]) {
					cEnd = cV;
					cStart = aV;
					cEdge = aE;
					return false;
				}
			}
		}
		return true;
	}

	static void gDetermine(int cV) {
		visited[cV] = true;
		for (int aI = 0; aI < aList[cV].size(); aI++) {
			int aV = aList[cV].get(aI);
			int eI = eList[cV].get(aI);
			if (!visited[aV]) {
				gDetermine(aV);
				eV[eI] = -val[aV];
				val[cV] -= val[aV];
				val[aV] = 0;
			}
		}
	}

}